<Kurt_Helf <at> nps.gov> writes: > > Greetings > In attempting to create a date variable based on month (e.g., > February, April, etc.) and year (e.g., 2006) data, wherein I converted > Month to a factor with Jan=1...Dec=12, I used the following command: > > data$Date<-mdy.date(month=data$Month,day=15,year=data$Year) > > however, I get a message "Error: trunc not meaningful for factors"
Have you tried data$Date<-mdy.date(month=as.numeric(data$Month),day=15,year=data$Year) (I like with() or transform() for making these cleaner: data <- transform(data,Date=mdy.date(month=as.numeric(Month),day=15,year=Year)) ______________________________________________ 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.