I'm making a plot with date on the x-axis, and I'm trying to set limits for the first and last date values in my data frame and only show every 28th label. There are 195 entries with dates in the format "%m-%d-%Y" and the x-axis is illegible with all labels showing. I changed my dates from characters to dates, but I keep getting the error
Error: Invalid input: date_trans works with objects of class Date only" when I try to set my x limits using xlim or use the limits argument within scale_x_date.
I also keep getting the error:
R Error Message: character string is not in a standard unambiguous format.
This is the code I tried most recently, though I've been scouring this site and others for the last two days and have tried various code iterations I've found for addressing this.
The code below gives me this error:
Error in if (all(is.finite(continuous_range_coord)) && diff(continuous_range_coord) < : missing value where TRUE/FALSE needed"
red.plot <- ggplot(collapse.red, aes(Date, RKM, group= Fish, colour=Fish)) +
geom_line() + geom_point() + theme(axis.text.x=element_text(angle=75, size=7,
color="black"))+ scale_x_date(date_breaks ="28 days", date_labels="%m-%d-%Y")+
coord_cartesian(xlim=c(as_date("2019-05-25","2022-06-25")))
When I run this code without the coord_cartesian argument, I get a plot with dates one month outside of the range I'm trying to represent.
I appreciate any suggestions anyone can offer!