[R] Formatting YYYY-MM after reading text file [RESOLVED]
Rich Shepard
rshepard at appl-ecosys.com
Fri Jun 26 21:04:06 CEST 2015
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:
$ stream : chr "B" "B" "B" "B" ...
$ sampdate:Class 'yearmon' num [1:2226] 1992 1992 1992 1992 1992 ...
$ param : chr "Cl" "SO4" "pH" "Cl" ...
$ quant : num 4 33 8.43 4 32 8.46 4 31 8.43 6 ...
which appears to do what's needed:
allchem
stream sampdate param quant
1 B Mar 1992 Cl 4.000
2 B Mar 1992 SO4 33.000
3 B Mar 1992 pH 8.430
4 B Apr 1992 Cl 4.000
5 B Apr 1992 SO4 32.000
6 B Apr 1992 pH 8.460
7 B May 1992 Cl 4.000
8 B May 1992 SO4 31.000
9 B May 1992 pH 8.430
10 B Jun 1992 Cl 6.000
Not having before worked with dates like this I'll soon see what happens
as the analyses proceed.
Rich
More information about the R-help
mailing list