Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread David Winsemius
On Jun 26, 2015, at 3:02 PM, Rich Shepard wrote: > On Fri, 26 Jun 2015, MacQueen, Don wrote: > >> I would have just assigned them all to the first day of the month, using >> as.Date( paste0(allchem$sampdate,'-01') ) >> (or maybe the middle of the month represented by the 15th) >> and then had a

Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread Rich Shepard
On Fri, 26 Jun 2015, MacQueen, Don wrote: I would have just assigned them all to the first day of the month, using as.Date( paste0(allchem$sampdate,'-01') ) (or maybe the middle of the month represented by the 15th) and then had a variable that was of the Date class in the base R (with which I

Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread MacQueen, Don
I would have just assigned them all to the first day of the month, using as.Date( paste0(allchem$sampdate,'-01') ) (or maybe the middle of the month represented by the 15th) and then had a variable that was of the Date class in the base R (with which I am familiar, no small consideration). Depe

Re: [R] Formatting YYYY-MM after reading text file

2015-06-26 Thread David Barron
as.yearmon(allchem$sampdate) worked for me. David On 26 June 2015 at 19:44, Rich Shepard wrote: > Data file 'example.dat' has this format: > > stream,sampdate,param,quant > B,1992-03,Cl,4 > B,1992-03,SO4,33 > B,1992-03,pH,8.43 > B,1992-04,Cl,4 > B,1992-04,SO4,32 > B,1992-04,pH,8.46 > B,1992-0

Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread Rich Shepard
On Fri, 26 Jun 2015, Rich Shepard wrote: allchem$sampdate <- as.yearmon(format(%Y-%m))allchem$sampdate Reading the yearmon help page again led me to try allchem$sampdate <- as.yearmon(allchem$sampdate) which produces the following structure: 'data.frame': 2226 obs. of 4 variables

[R] Formatting YYYY-MM after reading text file

2015-06-26 Thread Rich Shepard
Data file 'example.dat' has this format: stream,sampdate,param,quant B,1992-03,Cl,4 B,1992-03,SO4,33 B,1992-03,pH,8.43 B,1992-04,Cl,4 B,1992-04,SO4,32 B,1992-04,pH,8.46 B,1992-05,Cl,4 B,1992-05,SO4,31 B,1992-05,pH,8.43 It's read into R with allchem <- read.table('example.dat', stringsAsFacto