I think you're looking for something like this:
Date <- data.frame(stringsAsFactors = FALSE,
Time = c("Jan-81", "Feb-81", "Mar-81", "Apr-81", "May-81", "Jun-81",
"Jul-81", "Aug-81", "Sep-81", "Oct-81", "Nov-81", "Dec-81",
"Jan-82", "Feb-82", "Mar-82", "Apr-82", "May-82", "Jun-82",
"Jul-82", "Aug-82", "Sep-82", "Oct-82", "Nov-82", "Dec-82"),
Rainfall = c(45, 67, 209, 180, 131, 115, 104, 184, 133, 121, 80, 36,
43, 38, 101, 193, 208, 79, 81, 94, 109, 189, 156, 35) )
Date_mod <- within(data = Date,
expr = {
Time = as.Date(x = paste0("01-", Time),
format = "%d-%B-%y")
})
Date_mod
#> Time Rainfall
#> 1 1981-01-01 45
#> 2 1981-02-01 67
#> 3 1981-03-01 209
#> 4 1981-04-01 180
#> 5 1981-05-01 131
#> 6 1981-06-01 115
#> 7 1981-07-01 104
#> 8 1981-08-01 184
#> 9 1981-09-01 133
#> 10 1981-10-01 121
#> 11 1981-11-01 80
#> 12 1981-12-01 36
#> 13 1982-01-01 43
#> 14 1982-02-01 38
#> 15 1982-03-01 101
#> 16 1982-04-01 193
#> 17 1982-05-01 208
#> 18 1982-06-01 79
#> 19 1982-07-01 81
#> 20 1982-08-01 94
#> 21 1982-09-01 109
#> 22 1982-10-01 189
#> 23 1982-11-01 156
#> 24 1982-12-01 35
Created on 2019-05-08 by the reprex package (v0.2.1)
Hope this helps.
For future threads, please share your dataset in a copy-paste friendly format.
The dput function is very handy, if you have stored the dataset in some R object.
In case you've your dataset on a spreadsheet, check out the datapasta package. Take a look at the following link: