In my sleep data, I have a date column that was originally a character type. When plotted in ggplot(), it was listing every date in the x axis, making the labels very crowded.
Then I added the following code
dailytotals$EndDate <- as.Date(dailytotals$EndDate , "%m-%d-%Y")
which converted it to a date type. Then ggplot automatically created tick marks and labels every 15 days (for data that spans two months.
Note that the %Y (capitalized) recognizes a four digit year where %y (lower case) recognizes a two digit year.
No comments:
Post a Comment