To convert a character variable to a year format in R, you can use the as.Date()
or ymd()
function from the lubridate
package.
Here's an example using as.Date()
:
main.r217 chars10 lines
Output:
main.r11 chars2 lines
And here's an example using ymd()
:
main.r233 chars13 lines
Output:
main.r11 chars2 lines
gistlibby LogSnag