I have been given a csv with a column called month as a char variable with the first three letters of the month. E.g.:
\"Jan\", \"Feb\",\"Mar\",...\"Dec\" >
A couple of options using:
vec <- c("Jan","Dec","Jan","Apr")
are
> Months <- 1:12 > names(Months) <- month.abb > unname(Months[vec]) [1] 1 12 1 4
and/or
> match(vec, month.abb) [1] 1 12 1 4