Skip to content
Prev 165407 / 398506 Next

Using transform to add a date column to a dataframe

Prof Brian Ripley wrote:

            
That's a rather oblique way of saying that it actually does work with 
the unreleased version:

 > head(transform(airquality,Date=as.Date("1950-01-01")))
   Ozone Solar.R Wind Temp Month Day       Date
1    41     190  7.4   67     5   1 1950-01-01
2    36     118  8.0   72     5   2 1950-01-01
3    12     149 12.6   74     5   3 1950-01-01
4    18     313 11.5   62     5   4 1950-01-01
5    NA      NA 14.3   56     5   5 1950-01-01
6    28      NA 14.9   66     5   6 1950-01-01
 > R.version.string
[1] "R version 2.9.0 Under development (unstable) (2008-12-23 r47310)"