Convert months mmm to numeric

前端 未结 4 1804
粉色の甜心
粉色の甜心 2020-12-09 08:07

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\"
         


        
4条回答
  •  借酒劲吻你
    2020-12-09 08:37

    Use match and the predefined vector month.abb:

    tst <- c("Jan","Mar","Dec")
    match(tst,month.abb)
    [1]  1  3 12
    

提交回复
热议问题