Re: [R] Using transform to add a date column to a dataframe

2008-12-23 Thread Peter Dalgaard
Prof Brian Ripley wrote: A Date object is not a vector. In released versions of R, data.frame() only knows how to replicate vectors and factors. 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

Re: [R] Using transform to add a date column to a dataframe

2008-12-23 Thread Prof Brian Ripley
On Tue, 23 Dec 2008, Tom La Bone wrote: Gavin Simpson wrote: It says that the two arguments have different numbers of observations. The reason for which should now be pretty obvious as you provided a single Date whereas airquality has 153 observations. Thanks. I did look at ?transform b

Re: [R] Using transform to add a date column to a dataframe

2008-12-23 Thread Tom La Bone
Gavin Simpson wrote: > > > It says that the two arguments have different numbers of observations. > The reason for which should now be pretty obvious as you provided a > single Date whereas airquality has 153 observations. > Thanks. I did look at ?transform but I was a bit confused because t

Re: [R] Using transform to add a date column to a dataframe

2008-12-23 Thread Philipp Pagel
> I would like to add a column to the airquality dataset that contains the date > 1950-01-01 in each row. This method does not appear to work: > > > attach(airquality) > > data1 <- transform(airquality,Date=as.Date("1950-01-01")) > > Error in data.frame(list(Ozone = c(41L, 36L, 12L, 18L, NA, 28L,

Re: [R] Using transform to add a date column to a dataframe

2008-12-23 Thread Gabor Grothendieck
or not using transform at all: data1 <- airquality data1$Date <- as.Date("1950-01-01") # or in just one line: data1 <- replace(airquality, "Date", as.Date("1950-01-01")) On Tue, Dec 23, 2008 at 9:06 AM, Gavin Simpson wrote: > On Tue, 2008-12-23 at 05:24 -0800, Tom La Bone wrote: >> I would li

Re: [R] Using transform to add a date column to a dataframe

2008-12-23 Thread Gavin Simpson
On Tue, 2008-12-23 at 05:24 -0800, Tom La Bone wrote: > I would like to add a column to the airquality dataset that contains the date > 1950-01-01 in each row. This method does not appear to work: > > > attach(airquality) > > data1 <- transform(airquality,Date=as.Date("1950-01-01")) > > Error in

[R] Using transform to add a date column to a dataframe

2008-12-23 Thread Tom La Bone
I would like to add a column to the airquality dataset that contains the date 1950-01-01 in each row. This method does not appear to work: > attach(airquality) > data1 <- transform(airquality,Date=as.Date("1950-01-01")) Error in data.frame(list(Ozone = c(41L, 36L, 12L, 18L, NA, 28L, 23L, 19L, :