> 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,  : 
>   arguments imply differing number of rows: 153, 1
>  
> I can't decipher what the error message is trying to tell me. Any
> suggestions on how to do this?

You already got an answer solving your problem using transform
and rep. I would like to add that the automatic recycling would
have worked in this case:

airquality$Date <- as.Date('1950-01-01')

cu
        Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

______________________________________________
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.

Reply via email to