Hi, I have attached the data files to this note. I use this code: library(zoo) z1 <- read.zoo("baltimorefludata.txt", format = "%m/%d/%Y", header = TRUE) z2 <- read.zoo("baltimorew.txt", format = "%Y%m%d", header = TRUE) z3<-merge(z1,z2) write.table(z3, "fluweatherdata_baltimore2.txt", sep="\t") R is writing the other data to the file but not the dates... Is there a way to also write the dates to the file? Thank you!! Sincerely, tom Thomas Heiman, PhD Info Systems Eng, Sr The MITRE Corporation | Center for Enterprise Modernization Office: 703-983-2951 | theiman at mitre.org<mailto:theiman at mitre.org> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: baltimorew.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110524/db99639e/attachment.txt> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: baltimorefludata.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110524/db99639e/attachment-0001.txt>
On May 24, 2011, at 2:34 PM, Heiman, Thomas J. wrote:> Hi, > > I have attached the data files to this note. I use this code: > > library(zoo) > z1 <- read.zoo("baltimorefludata.txt", format = "%m/%d/%Y", header = > TRUE) > z2 <- read.zoo("baltimorew.txt", format = "%Y%m%d", header = TRUE) > > z3<-merge(z1,z2) > > write.table(z3, "fluweatherdata_baltimore2.txt", sep="\t") > > R is writing the other data to the file but not the dates... Is > there a way to also write the dates to the file? Thank you!!?write.zoo -- David Winsemius, MD West Hartford, CT
I think if you attach the output file would make clear. I guess it is very likely your merge has the problem, not the write.table. You may need "by" parameter in merge based on the date. It also could be date value is converged to numeric value, in this case you just need to convert it back. --- On Tue, 5/24/11, Heiman, Thomas J. <theiman@mitre.org> wrote: From: Heiman, Thomas J. <theiman@mitre.org> Subject: [R] writing dates to a file To: "R-help@r-project.org" <R-help@r-project.org> Date: Tuesday, May 24, 2011, 2:34 PM Hi, I have attached the data files to this note. I use this code: library(zoo) z1 <- read.zoo("baltimorefludata.txt", format = "%m/%d/%Y", header = TRUE) z2 <- read.zoo("baltimorew.txt", format = "%Y%m%d", header = TRUE) z3<-merge(z1,z2) write.table(z3, "fluweatherdata_baltimore2.txt", sep="\t") R is writing the other data to the file but not the dates... Is there a way to also write the dates to the file? Thank you!! Sincerely, tom Thomas Heiman, PhD Info Systems Eng, Sr The MITRE Corporation | Center for Enterprise Modernization Office: 703-983-2951 | theiman@mitre.org<mailto:theiman@mitre.org> -----Inline Attachment Follows----- ______________________________________________ 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. [[alternative HTML version deleted]]
On Tue, May 24, 2011 at 2:34 PM, Heiman, Thomas J. <theiman at mitre.org> wrote:> Hi, > > I have attached the data files to this note. ? I use this code: > > library(zoo) > z1 <- read.zoo("baltimorefludata.txt", format = "%m/%d/%Y", header = TRUE) > z2 <- read.zoo("baltimorew.txt", format = "%Y%m%d", header = TRUE) > > z3<-merge(z1,z2) > > write.table(z3, "fluweatherdata_baltimore2.txt", sep="\t") > > R is writing the other data to the file but not the dates... ?Is there a way to also write the dates to the file? ?Thank you!! >z3 is a zoo object so you want write.zoo, not write.table. See ?write.zoo. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
On May 24, 2011, at 4:00 PM, Andy Zhu wrote:> I think if you attach the output file would make clear. I guess it > is very likely your merge has the problem, not the write.table.No. The merge woks fine. write.table is not writing the date indices but write.zoo would. Tested. -- david.> You may need "by" parameter in merge based on the date. It also > could be date value is converged to numeric value, in this case you > just need to convert it back. > > > --- On Tue, 5/24/11, Heiman, Thomas J. <theiman at mitre.org> wrote: > > From: Heiman, Thomas J. <theiman at mitre.org> > Subject: [R] writing dates to a file > To: "R-help at r-project.org" <R-help at r-project.org> > Date: Tuesday, May 24, 2011, 2:34 PM > > Hi, > > I have attached the data files to this note. I use this code: > > library(zoo) > z1 <- read.zoo("baltimorefludata.txt", format = "%m/%d/%Y", header = > TRUE) > z2 <- read.zoo("baltimorew.txt", format = "%Y%m%d", header = TRUE) > > z3<-merge(z1,z2) > > write.table(z3, "fluweatherdata_baltimore2.txt", sep="\t") > > R is writing the other data to the file but not the dates... Is > there a way to also write the dates to the file? Thank you!! > > Sincerely, > > tom > > Thomas Heiman, PhD > Info Systems Eng, Sr > The MITRE Corporation | Center for Enterprise Modernization > Office: 703-983-2951 | theiman at mitre.org<mailto:theiman at mitre.org> > > -----Inline Attachment Follows----- > > ______________________________________________ > R-help at 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. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT