Dear R users,

I have a data with  month and year columns which are both characters
and wanted to create a new column like Jan-1999
with the following code. The result is all NA for the month part. What
is wrong with the and what is the right way to combine the two?

ddf$MonthDay <- paste(month.abb[ddf$month], ddf$Year, sep="-" )


Thanks

> dput(ddf)
structure(list(month = c("01", "02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12"), Year = c("1999", "1999",
"1999", "1999", "1999", "1999", "1999", "1999", "1999", "1999",
"1999", "1999"), views = c(42, 49, 44, 38, 37, 35, 38, 39, 38,
39, 38, 46), MonthDay = c("NA-1999", "NA-1999", "NA-1999", "NA-1999",
"NA-1999", "NA-1999", "NA-1999", "NA-1999", "NA-1999", "NA-1999",
"NA-1999", "NA-1999")), .Names = c("month", "Year", "views",
"MonthDay"), row.names = 109:120, class = "data.frame")
>

______________________________________________
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