Re: [R] zoo: merging aggregated zoo-objects fails
Hello Gabor, I just tried dput() and it seems that running aggregate deletes the following information from zoo objects: origin = structure(c(1, 1, 1970)) So before merging I added: chron(index(z),origin=c(1,1,1970))-index(z) which solves my problem. Is that behaviour of aggregate.zoo intended or a bug? Yours sincerely, gunnar -- View this message in context: http://www.nabble.com/zoo%3A-merging-aggregated-zoo-objects-fails-tp25633345p25643930.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] zoo: merging aggregated zoo-objects fails
Hello Gabor, thanks for your reply. Please excuse the insufficient description of my problem. I hope this one is better: #Importing my data works basically like this dts - dates(c(19700201,19700201,19700201,19700202,19700202),format=ymd) tms - times(paste(c(21:00, 22:00, 23:00,00:00, 01:00),0,sep=:),format=h:m:s) x - chron(dates=dts,times=tms) z - zoo(c(174.055,174.067,174.076,174.085,174.091),x) #Because I need daily values I run: z - aggregate(z,trunc,mean) #And because I deal with different data sets and need to sum them up I run: m - merge(z,z) When R executes merge() I get the following error message: Fehler in matrix(unlist(lapply(dots, origin)), nrow = 3) : Versuch ein Attribut von NULL zu setzen (Sorry that it's German. It says something like 'Error... Try to set attribute NULL') It's curious that there is no error when I first run merge() and than aggregate(), but this is not possible due to the rest of the programm. So why is merging not possible? Thanks in advance, gunnar R version 2.9.1 (Debian Lenny, XFCE 4.4, EMACS 22.2.1, ESS 5.3.8) -- View this message in context: http://www.nabble.com/zoo%3A-merging-aggregated-zoo-objects-fails-tp25633345p25643639.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] zoo: merging aggregated zoo-objects fails
This looks like a problem in the chron package. Define: c.chron - function(...) chron(do.call(c, lapply(list(...), unclass))) and then try it again. I will discuss it with the chron maintainer. On Mon, Sep 28, 2009 at 6:41 AM, gunnar.p pr...@uni-potsdam.de wrote: Hello Gabor, thanks for your reply. Please excuse the insufficient description of my problem. I hope this one is better: #Importing my data works basically like this dts - dates(c(19700201,19700201,19700201,19700202,19700202),format=ymd) tms - times(paste(c(21:00, 22:00, 23:00,00:00, 01:00),0,sep=:),format=h:m:s) x - chron(dates=dts,times=tms) z - zoo(c(174.055,174.067,174.076,174.085,174.091),x) #Because I need daily values I run: z - aggregate(z,trunc,mean) #And because I deal with different data sets and need to sum them up I run: m - merge(z,z) When R executes merge() I get the following error message: Fehler in matrix(unlist(lapply(dots, origin)), nrow = 3) : Versuch ein Attribut von NULL zu setzen (Sorry that it's German. It says something like 'Error... Try to set attribute NULL') It's curious that there is no error when I first run merge() and than aggregate(), but this is not possible due to the rest of the programm. So why is merging not possible? Thanks in advance, gunnar R version 2.9.1 (Debian Lenny, XFCE 4.4, EMACS 22.2.1, ESS 5.3.8) -- View this message in context: http://www.nabble.com/zoo%3A-merging-aggregated-zoo-objects-fails-tp25633345p25643639.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-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] zoo: merging aggregated zoo-objects fails
Dear all, I have several text files looking like this: 9063032 19700201 22:00 174.067 9063032 19700201 23:00 174.076 9063032 19700202 00:00 174.085 9063032 19700202 01:00 174.091 9063032 19700202 02:00 174.094 9063032 19700202 03:00 174.091 9063032 19700202 04:00 174.082 9063032 19700202 05:00 174.079 And I run this loop: for (j in 1:nr.of.files) { #Import: DF - read.table(path,header=FALSE,na.string='-', colClasses=c(NULL,character,character,numeric)) z - zoo(DF$V4,chron(dates=DF$V2,times=paste(DF$V3,0,sep=:), format=c(dates=ymd,times=h:m:s))) #getting daily values: x - aggregate(z,trunc,mean) #summing everything up in one nr.of.files-dimensional zoo-object if (j 1) final - merge(final,x) else final - x } Unfortunately I get the following error message: Fehler in matrix(unlist(lapply(dots, origin)), nrow = 3) : Versuch ein Attribut von NULL zu setzen (Error ... Trying to set an attribute NULL) There is no error when I first run merge() and then aggregate(), but this is not possible due to the rest of the program. Does any one have a clue? regards, gunnar (R vers.2.9.1 (Debian Lenny, XFCE 4.4, EMACS 22.2.1, ESS 5.3.8)) -- View this message in context: http://www.nabble.com/zoo%3A-merging-aggregated-zoo-objects-fails-tp25633345p25633345.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] zoo: merging aggregated zoo-objects fails
Please read the last line to every message on r-help. In particular make it reproducible and minimal. The code you post should look like this where you have cut down DF1, DF2 and DF3 to the smallest number of rows that still exhibits the error. DF1 - ...output from dput(DF1) DF2 - ...output from dput(DF2)... DF3 - ...output from dput(DF3)... z1 - zoo(...) z2 - zoo(...) z3 - zoo(...) m - merge(z1, z2) m2 - merge(z3, m) # error On Sun, Sep 27, 2009 at 8:42 AM, gunnar.p pr...@uni-potsdam.de wrote: Dear all, I have several text files looking like this: 9063032 19700201 22:00 174.067 9063032 19700201 23:00 174.076 9063032 19700202 00:00 174.085 9063032 19700202 01:00 174.091 9063032 19700202 02:00 174.094 9063032 19700202 03:00 174.091 9063032 19700202 04:00 174.082 9063032 19700202 05:00 174.079 And I run this loop: for (j in 1:nr.of.files) { #Import: DF - read.table(path,header=FALSE,na.string='-', colClasses=c(NULL,character,character,numeric)) z - zoo(DF$V4,chron(dates=DF$V2,times=paste(DF$V3,0,sep=:), format=c(dates=ymd,times=h:m:s))) #getting daily values: x - aggregate(z,trunc,mean) #summing everything up in one nr.of.files-dimensional zoo-object if (j 1) final - merge(final,x) else final - x } Unfortunately I get the following error message: Fehler in matrix(unlist(lapply(dots, origin)), nrow = 3) : Versuch ein Attribut von NULL zu setzen (Error ... Trying to set an attribute NULL) There is no error when I first run merge() and then aggregate(), but this is not possible due to the rest of the program. Does any one have a clue? regards, gunnar (R vers.2.9.1 (Debian Lenny, XFCE 4.4, EMACS 22.2.1, ESS 5.3.8)) -- View this message in context: http://www.nabble.com/zoo%3A-merging-aggregated-zoo-objects-fails-tp25633345p25633345.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-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.