I have the following date and it's in a 'month-year' format. However, to plot the dates on the x-axis of a ggplot2 graphic, I'm trying to convert them into a date format. With the as.Date function, it produces NA values because no 'day' value is provided. So beyond pasting the day into each date using the paste() function, how can I handle adjusting the dates so that I can plot them.
date = c("Jan-10","Feb-10","Mar-10","Jun-10","Jul-10")
date
date = as.Date(date, "%m/%d/%Y") # doesn't work
date = as.Date(as.yearmon(date, format="%y-%b")) # doesn't work
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…