[R] aggregate vs merge
Hello Can someone explain me the difference between aggregate and merge, please? I've read the help on both commands but I don't understant the difference. thanks -- View this message in context: http://r.789695.n4.nabble.com/aggregate-vs-merge-tp2255300p2255300.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] executable script
Maybe he wants to compile it to an exe file in order to make it faster. -- View this message in context: http://r.789695.n4.nabble.com/executable-script-tp839859p2255307.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] working with zoo time index ??
Hello Where could I find examples on how to work with the time index in a timeseries or zoo series? Let say I've got this series DATA 1990-01-01 10:00:00 0.900 1990-01-01 10:01:00 0.910 1990-01-01 10:03:00 0.905 1990-01-01 10:04:00 0.905 1990-01-01 10:05:00 0.890 ... 2000-12-31 20:00:00 0.992 How do I make simple calculations such as ... ? Calculate the mean of the first data every day. (mapply, for loop, tapply ?) Transform data to a table, with dates in one axis and times in the other. thanks -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2255804.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
Hi thanks Let say data are written like this: 1990-01-01 10:01:00 , 0.910 1990-01-01 10:03:00 , 0.905 Would it be ok to read it with theses lines or is better to use your way? tmp <- read.table("demo2.txt", sep = ",") z <- zoo(tmp[, 2], as.Date(as.chron(tmp[, 1]), format = "%Y-%m-%d %H:%M:%S")) regards -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2257222.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
I can't see where you check the date. -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2257226.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
Hi I'll ask in a different way... I have all this in a file.txt 1990-01-01 10:00:00 , 0.900 # element 1 1990-01-01 10:01:00 , 0.910 # element 2 1990-01-01 10:03:00 , 0.905 # element 3 1990-01-01 10:04:00 , 0.905 # element 4 1990-01-01 10:05:00 , 0.890 # element 5 .. 2000-12-30 20:00:00 , 11.233# element 3323232 How do I loop through the index? first element 1, then element 2, then the third... How do I extract the day or the hour or the minutes from an element from the index(element n)? -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2257591.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
I said taking the first element everyday, but that was just an example, I could need one every 2 hours or something more complicated such as one every hour if the former one was non null. -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2257641.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
OK, I've seen now your reply now thanks very much -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2257958.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
thanks How can I do it without using "aggregate"? In other languages they use commands like Time[i] or Date[i]<>Date[i-1] were i is the cell -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2257952.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
Hi again. I have several files with data like above. Each file has different periods. My idea is to use zoo in order to do this... Converting all data to same period, the smaller one, 5 minutes. Whenever a datum doesn't exist copy the last one. (carry forward) Add data of every 5 minutes getting a new series. With the new series run a loop: every day I save the first data I substract every datum within this day from the saved data for tihs day And I check if that substraction accomplishes some test, for example equals a number. I this test is not fulfilled I continue to the end of the day. Then I store the value of the subratcion last an I start with the next day. If it's fulffiled I store the value of the substraction that fulfilled the test and I jump directly to the next day. Can you do all this with "aggregate" ? -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2258637.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
What if I use something like myvalue = coredata[ index[x] == as.Date("2009-03-01") ] -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2258802.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with zoo time index ??
I've read all these documents and some other. -- View this message in context: http://r.789695.n4.nabble.com/working-with-zoo-time-index-tp2255804p2259106.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R vs SAS and Revolution R
Hello How do you compare R to SAS in terms of speed and management of large datasets? What about Revolution R? I've seen on their site, they claim that Revolution R is much faster than R and it's multithread... Can you really notice the difference?. What dissadvantage does it have? I think it's based on R 2.10. but R already issued the version 2.12 Regards What alternative to R would you use in order to merge asynchronus time series?. SAS, Stata, eViews...? -- View this message in context: http://r.789695.n4.nabble.com/R-vs-SAS-and-Revolution-R-tp2261149p2261149.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merging and adding time series
Hello I have two series (that can have with different frequencies or with missing values). I merge them and use na.locf, getting a zoo objet with a common index and two core columns. How can I add this columns getting a new zoo series? Any other way of adding two asynchronou series? regards -- View this message in context: http://r.789695.n4.nabble.com/merging-and-adding-time-series-tp2274125p2274125.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] merging and adding time series
If I just add them (without merging) I get only the common elements. rowsum doesn't work for me -- View this message in context: http://r.789695.n4.nabble.com/merging-and-adding-time-series-tp2274125p2274131.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] multivariate graphs, averaging on some vars
Hello I have a table of this kind: functionx1 x2 x3 2.232 1 1 1.00 2.242 1 1 1.01 2.732 1 1 1.02 2.770 1 2 1.00 1.932 1 2 1.01 2.132 1 2 1.02 3.222 1.2 1 1 . ... .. .. The table represents the values of a function(x1, x2, x3) for each combination x1, x2, x3. I'd like to generate a plot where each point has the coordinates x=x1, y=x2, z=(mean of function(x1, x2) for all different x3). How can I do it? fox example, with the data from above the first point would be: x=x1=1, y=x2=1, z=(2.232+2.242+2.732)/3 In truth, my table has many columns and I want to take the mean over all the variables except the ones I represent at the axes, for example represent function(x1, x2) taking the mean over x3, x4, x5. Or using the maximum value of function(x1, x2) over all x1, x2, x3 How can I do it? Another question. How can I plot function(x1, x2, x3) with x=x1, y=x2, z=x3, different colours=function thanks -- View this message in context: http://r.789695.n4.nabble.com/multivariate-graphs-averaging-on-some-vars-tp2292039p2292039.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] multivariate graphs, averaging on some vars
Thank you very much, I'll try it. About my question on graphics with colour... Imagine I have a function y=y(x1, x2, x3), I'd need four dimensions to graph x1, x2, x3, and y. My idea is to use the typical 3D plot adding the information of the additional fourth variable 'y to the colour of the point. What package do you recommend to do it? Any interactive plotting package? thx -- View this message in context: http://r.789695.n4.nabble.com/multivariate-graphs-averaging-on-some-vars-tp2292039p2292270.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bug on chron
hello I think I've found a bug I don't know if it's a chron bug or a R one. (05/12/05 23:00:00) +1/24 gives (05/12/05 24:00:00) instead of (05/13/05 00:00:00) it looks like the same but it's not because when you get the date of this datetime it says day 12 instead of 13. Please, forward it to the place where this bugs are supposed to be posted. cheers -- View this message in context: http://r.789695.n4.nabble.com/Bug-on-chron-tp2533135p2533135.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug on chron
Something strange. Your example work but... I have a zoo object. I extract its element 21 >> index(test[21]) > [1] (05/12/05 23:00:00) > >> index(test[21])+1/24 > [1] (05/12/05 24:00:00) > > Why 24:00 ? >> packageDescription("chron")$Version > [1] "2.3-35" >> R.version.string > [1] "R version 2.11.1 (2010-05-31)" > packageDescription("zoo")$Version [1] "1.7-0" cheers -- View this message in context: http://r.789695.n4.nabble.com/Bug-on-chron-tp2533135p2533194.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug on chron
I don't know. You can look at the file, is very short. http://r.789695.n4.nabble.com/file/n2533223/test test -- View this message in context: http://r.789695.n4.nabble.com/Bug-on-chron-tp2533135p2533223.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug on chron
I've tried with other zoo series and I have always the same problem. -- View this message in context: http://r.789695.n4.nabble.com/Bug-on-chron-with-zoo-tp2533135p2533287.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] adding zeroes after old zeroes in a vector ??
Hello Imagine I have a vector with ones and zeroes I write it compactly: 011100101 I need to get a new vector replacing the "N" ones following the zeroes to new zeroes. For example for N = 3 011100101 becomes 00010 I can do it with a for loop but I've read is not a good practice, How can I do it then? cheers My vector is a zoo series, indeed, but I guess it doesn't make any difference. -- View this message in context: http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2534824.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding zeroes after old zeroes in a vector ??
Hi I'll study your answers. I could also try gsub("01", "00", x) N times but it could be very slow if N is large In fact when I wrote 10011I mean a vector 1 1 1 1 1 0 0 1 1 not a string, but I wrote it more compactly. I also could by shifting the elements of the vector one position and ANDing the result with the original. And again shifting 2 postions and so on up to N. But it's very slow. -- View this message in context: http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2534982.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding zeroes after old zeroes in a vector ??
Hello, Dennis Do you prefer your way or this one? http://stackoverflow.com/questions/3686982/r-adding-zeroes-after-old-zeroes-in-a-vector stackoverflow, Jonathan http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2534995.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding zeroes after old zeroes in a vector ??
Hello Your code gives a vector with length different to the original one -- View this message in context: http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2535017.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding zeroes after old zeroes in a vector ??
Hi z shifting: c(1,z[-length(z)]) then for N=1 tmp <- c(1,z[-length(z)])*z or c(1,z[-length(z)])&&z length of the vector 100 (Indeed is more complicated because I need to use the result of all this with zoo time series) Typical N 10 to 400 typical number of zeros 10% I'll try all your new suggestions -- View this message in context: http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2535224.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding zeroes after old zeroes in a vector ??
OK thanks to all, I don't need, more Up to this moment the fastest working code is Jonathan Chang's http://stackoverflow.com/questions/3686982/r-adding-zeroes-after-old-zeroes-in-a-vector/3689360#3689360 rr <- rle(tmp) ## Pad so that it always begins with 1 and ends with 1 if (rr$values[1] == 0) { rr$values <- c(1, rr$values) rr$lengths <- c(0, rr$lengths) } if (rr$values[length(rr$values)] == 0) { rr$values <- c(rr$values, 1) rr$lengths <- c(rr$lengths, 0) } zero.indices <- seq(from=2, to=length(rr$values), by=2) one.indices <- seq(from=3, to=length(rr$values), by=2) rr$lengths[zero.indices] <- rr$lengths[zero.indices] + pmin(rr$lengths[one.indices], n) rr$lengths[one.indices] <- pmax(0, rr$lengths[one.indices] - n) inverse.rle(rr) -- View this message in context: http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2535573.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Substitute NAs by zero
Hello How can I substitute all NA values by zero in a R zoo series? I've been reading about na.locf and na.omit but I think none of them do what I need. thanks. -- View this message in context: http://r.789695.n4.nabble.com/Substitute-NAs-by-zero-tp2546715p2546715.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] change tick spacing on the axis of a plot.
Hello How can I change the spacing of tick marks on the axis a plot? What parameters should I use on base plot or on rgl? cheers -- View this message in context: http://r.789695.n4.nabble.com/change-tick-spacing-on-the-axis-of-a-plot-tp2553149p2553149.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simplify, several Ave or aggregates
Hello. How can I write this all in one line? mydata is a zoo series, limit is a numeric vector of the same size tmp <- ave(coredata(mydata),as.Date(index(mydata)),FUN = function(x) ( (cummax(x)-x )) ) tmp <- (tmp < limit) final <- ave(coredata(tmp),as.Date(index(mydata)),FUN = function(x) cumprod( x) ) I've tried to use two vectors as argument to ave(...) but it seems to accept just one even if I join them into a maxtrix. This is just an example, but any other function could be use. Here I need to compare the value of cummax(mydata)-mydata with a numeric vector and once it surpasses it I'll keep zeros till the end of the day. The cummax is calculated from the beginning of each day. If limit were a single number instead of a vector (with different possible numbers) I could write it: ave(coredata(mydata),as.Date(index(mydata)),FUN = function(x) cumprod( (cummax(x)-x ) < limit) ) But I can't introduce there a vector longer than x (with the length of each day) and I don't know how to introduce it as another argument in ave() cheers -- View this message in context: http://r.789695.n4.nabble.com/Simplify-several-Ave-or-aggregates-tp2719363p2719363.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R: Why this deosn't work?, matrix, rounding error?
Hello Why this works: ncota <- 1 nslope <- 29 resul <- matrix(rep(0,ncota*nslope*4),ncota*nslope,4) But this doesn't? ncota <- 1 sini <- 0.1; sfin <- 1.5; spaso <- 0.05; nslope <- 1+((sfin-sini)/spaso) resul <- matrix(rep(0,ncota*nslope*4),ncota*nslope,4) I guess the problem is that the division gives a noninteger number. How can I get the second one work? I need to create a zero matrix with its size calculated from a calculation. cheers -- View this message in context: http://r.789695.n4.nabble.com/R-Why-this-deosn-t-work-matrix-rounding-error-tp2968527p2968527.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R: Why this deosn't work?, matrix, rounding error?
It's a problem much bigger. I use a matrix to store the results of a bigger problem. I loop through several variables and store the results of a computation on that matrix. At the beginning of the problem I initialize the matrix to zeros and I calculate its size from some input. And that seems not to work well maybe because of some rounding error. -- View this message in context: http://r.789695.n4.nabble.com/R-Why-this-deosn-t-work-matrix-rounding-error-tp2968527p2968662.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R: Why this deosn't work?, matrix, rounding error?
Hello I've seen the answer at stackoverflow. They also said I must use zapsmall to avoid roundup problems. I didn't expect this behaviour when division gives an integer number. -- View this message in context: http://r.789695.n4.nabble.com/R-Why-this-deosn-t-work-matrix-rounding-error-tp2968527p2969459.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] number format, writing 1e-5 instead of 0.00001
Hello I've used read.table to read a file that contains numbers such as 0.1 when I write them back with write.table those numbers appear as 1e-5 How can I keep the old format? thanks -- View this message in context: http://r.789695.n4.nabble.com/number-format-writing-1e-5-instead-of-0-1-tp3003831p3003831.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to select not continous rows?
Hello How can I select several not continuous rows ? If I wanted to select rows 1 to 7 I'll write mydata[,1:7] But what if I need to select rows 1 to 5 and 10 to 15? -- View this message in context: http://r.789695.n4.nabble.com/How-to-select-not-continous-rows-tp3003840p3003840.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] strftime vs strptime ??
Hello Could anyone explain me the difference between strftime vs strptime, please ? I've read the help but it's a little bit cionfusing for me. cheers -- View this message in context: http://r.789695.n4.nabble.com/strftime-vs-strptime-tp3018865p3018865.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot vs print ??
Hello What's the differente betwen using "plot" and using "print" in order to plot a graph? For example in order to plot the result of a histogram. cheers -- View this message in context: http://r.789695.n4.nabble.com/plot-vs-print-tp3045256p3045256.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rgl, multiple graphics ??
Hello How can I get multipanel conditioning graphics with rgl as I do with lattice "|" For example I have three variables x, y, z, w. Where x,y,z are continuous and w is categorical or discrete. I want to use plot3d(x,y,z) for each value of w in a panel something like plot3d(z~x*y|w) cheers -- View this message in context: http://r.789695.n4.nabble.com/rgl-multiple-graphics-tp3047005p3047005.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rgl, multiple graphics ??
Hello How can I get multipanel conditioning graphics with rgl as I do with lattice "|" For example I have three variables x, y, z, w. Where x,y,z are continuous and w is categorical or discrete. I want to use plot3d(x,y,z) for each value of w in a panel something like plot3d(z~x*y|w) cheers -- View this message in context: http://r.789695.n4.nabble.com/rgl-multiple-graphics-tp3047006p3047006.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot vs print ??
Hello everybody. My question arised from the output of lattice's histogram. But might be extended to any other object that could be printed. I think I've understood your answers, print calls the plot function when the object to be printed is a trellis plot object. I guess I can always use plot instead. ?? -- View this message in context: http://r.789695.n4.nabble.com/plot-vs-print-tp3045256p3048408.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rgl, multiple graphics ??
Hello I just get one plot How can I concoct several rgl plots? -- View this message in context: http://r.789695.n4.nabble.com/rgl-multiple-graphics-tp3047006p3048434.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] when to use textConnection ??
Hello. I don't uderstant when to use textConnection and when not. Some examples do it, some not. I've even seen something like con <- textConnection(rev(rev(ReadLines('data.txt'))[-(1:2])) data <- read.table(con) close(con) -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327132.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when to use textConnection ??
OK, thanks Some time ago I asked in the forum how to read data from a file in order to use it with zoo. Someone suggested to use textConnection That's why I'm a little bit confused. I guess I don't need to use textConnection in order to read from files, it's just for text copied from other sources (such as the clipboard) -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327224.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when to use textConnection ??
Gabor Grothendieck wrote: > > > Note that zoo does have the read.zoo function which can read a file > returning a zoo object. See help(read.zoo) . > > I know, but there are many different ways to read and I wanted to know what's the proper in my case. For example I've seen these ones, what's the difference? read.zoo("file.txt", sep = ",", FUN = as.chron, format = "%Y-%m-%d %H:%M:%S" read.zoo("file.txt", index = 1:2, FUN = as.chron(paste(x[,1], x[,2]))) , format = "%Y-%m-%d %H:%M:%S") I need to read from a file with this format: date timevalue 1999-11-11 10:20:00 1. thx -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327617.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when to use textConnection ??
I've just seen that sep sep cannot be "," because there are not commas in the file. but I want it to take the first and second columns (date and time) as a whole, the index. -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327622.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when to use textConnection ??
Error in .subset(x, j) : invalid subscript type 'list' Maybe is because I'm using Revolution Analytics and is based on an older version of R. I use it because I need to manage very big files and the common version of R shows me an out of memory error. -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327642.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when to use textConnection ??
Oh, I got it with these code: tmp <- read.table("file.txt") mydata <- zoo(z$V3, as.chron(paste(z$V1,z$V2))) but that way I cannot specify the format of the date cheers -- View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327656.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] remove rows ??
Hello I have a file with this format 2005-01-03 09:05 0.00 2005-01-03 09:10 0.01 2005-01-03 09:15 0.02 2005-01-03 09:20 0.03 2005-01-03 09:25 0.04 2005-01-03 09:30 0.05 2005-01-03 09:35 0.06 2005-01-03 09:40 0.07 2005-01-03 09:45 0.08 2005-01-03 09:50 0.09 2005-01-03 09:55 0.10 2005-01-03 10:00 0.00 2005-01-03 10:05 0.00 some data may be missing And I need to keep just the rows with time multiple of 15sec 2005-01-03 09:15 0.02 2005-01-03 09:30 0.05 2005-01-03 09:45 0.08 2005-01-03 10:00 0.00 ... How can I do it? thanks -- View this message in context: http://r.789695.n4.nabble.com/remove-rows-tp2328312p2328312.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove rows ??
I get this message "character string is not in a standard unambiguous format" and if I try to use a zoo object "Error en `$.zoo`(final, V2) : not possible for univariate zoo series" cheers -- View this message in context: http://r.789695.n4.nabble.com/remove-rows-tp2328312p2328487.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove rows ??
Now it works I was reading from a file DF <- read.table("prueba.txt") DF[!as.POSIXlt(DF$V1)[['min']] %% 10,] didn't do anything, then I tried zz[!as.POSIXlt(zz$V2)[['min']] %% 10,] that caused an error Error en as.POSIXlt.character(as.character(x)) : character string is not in a standard unambiguous format what if you use zoo and chron instead? I say that because I'd like to make more computation later with zoo. and what I relly need is to keep the last data in each 15min piece. Giving it a 15min time format commonly I'll have one data every 5 min, but sometimes some could be missing or not be a 5min multiple. 2005-01-03 09:04 0.01 -> ignore because the next one is nearer to 15 2005-01-03 09:05 0.02 -> 2005-01-03 09:15 0.02 2005-01-03 09:24 0.03 -> 2005-01-03 09:30 0.03 -- View this message in context: http://r.789695.n4.nabble.com/remove-rows-tp2328312p2328517.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Different way of aggregating
Hi Usually "aggregate" is used to calculate things such as the sum of all data on the first day, the sum next day, and so on. But how can I calculate the mean of the first hour of all days, the mean of the second hour of all days, and so on. ??? That's Most examples: today at 1am + today at 2am + today at 3am +-> sum today tomorrow at 1am + tomorrow at 2am + tomorrow at 3am + -> sum tomorrow .. aggregate(data, as.Date,sum) But what I need is: data today at 1 + data tomorrow at 1 + data in two days at 1 + .-> sum at 1am data today at 2 + data tomorrow at 2 + data in two days at 2 + .-> sum at 2am data today at 3 + data tomorrow at 3 + data in two days at 3 + .-> sum at 3am . How can I do it?? cheers -- View this message in context: http://r.789695.n4.nabble.com/Different-way-of-aggregating-tp2330497p2330497.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Different way of aggregating
Phil Spector wrote: > > > For chron objects: > > aggregate(thedata$value,list(hour=hours(thedata$date)),mean) > > Ok, thanks, that's what I need. Now it seems so easy... Could you tell me why we write... ? aggregate(thedata$value,list(hour=hours(thedata$date)),mean) instead of just aggregate(thedata$value,hours(thedata$date),mean) thanks -- View this message in context: http://r.789695.n4.nabble.com/Different-way-of-aggregating-tp2330497p2331072.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] aggregate with cummax ??
Hello I have a time series (with index of type chron) and I need to calculate the cummax(mydata)-mydata on every day separately. I've tried this aggregate(mydata, as.date, cummax) but aggregate can only produce a single scalar result for each subset instead of a vector. I've tried with tapply and lapply but I don't know how to do it. Can anyone help me, plese cheers -- View this message in context: http://r.789695.n4.nabble.com/aggregate-with-cummax-tp2331991p2331991.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate with cummax ??
Hi Just in case somebody could be interested I've found that unlist(lapply(split(mydata,as.Date), cummax)) could make the job but I don't know if it's the proper way if I want to use zoo objects. Any suggestion?? -- View this message in context: http://r.789695.n4.nabble.com/aggregate-with-cummax-tp2331991p2332653.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Repeat the first day data through all the day. Zoo
down vote favorite Hello I have a zoo series. It lasts 10 years and its frequency is 15min. I'd like to get a new zoo series (or vector) with the same number of elements, whith each element equal to the first element of the day. That's, The first element everyday is repeated throughout the wole day. This is not same as aggregate(originalseries,as.Date,head,1) because this gives a vector with just one element for each day. cheers -- View this message in context: http://r.789695.n4.nabble.com/Repeat-the-first-day-data-through-all-the-day-Zoo-tp2338069p2338069.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Repeat the first day data through all the day. Zoo
thanks I'll try them, Why do you use the brackets in zz[] ? -- View this message in context: http://r.789695.n4.nabble.com/Repeat-the-first-day-data-through-all-the-day-Zoo-tp2338069p2338266.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Repeat the first day data through all the day. Zoo
# duplicated / na.locf doesn't work it says Error in fix.by(by.x, x) : 'by' must specify valid column(s) if I use ifelse instead of ifelse.zoo it works but it gives me a non zoo vector. Myabe is because my zoo version is older. cheers -- View this message in context: http://r.789695.n4.nabble.com/Repeat-the-first-day-data-through-all-the-day-Zoo-tp2338069p2338409.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rendering or raytracing?
Hello Is there any package for rendering or raytracing? -- View this message in context: http://r.789695.n4.nabble.com/rendering-or-raytracing-tp4213944p4213944.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rendering or raytracing?
Hi Then OK, I mean raytracing directly with some R package. Or maybe some optics package I've seen there exist an optics package called planar but it's only for reflection and transmission at planar interfaces. -- View this message in context: http://r.789695.n4.nabble.com/rendering-or-raytracing-tp4213944p4214608.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.