I have been trying to figure out this error for a while today. I’ve read several other threads and can’t seem to find a fix. I have checked the structure of my dataframe and the vector (date) is in the correct format, but I’m still getting the error. Any idea what the problem is? Code below.
> str(df)
'data.frame': 29 obs. of 4 variables:
$ date: POSIXct, format: "2022-11-22" "2023-05-18" ...
$ dist: Factor w/ 8 levels "0.5","2","6",..: 1 1 1 2 2 2 2 3 3 3 ...
$ mean: num 5 2.33 7.83 2.89 3 ...
$ se : num NA NA 4.833 0.909 NA ...
> limits<-aes(xmax = mean + se, xmin = mean - se)
> pal=viridisLite::viridis(9)
> ggplot(df, aes(x=date, y=mean, xmin=mean-se, xmax=mean+se,
+ group=dist, color=dist)) +
+ geom_point(size=2, alpha=0.7) +
+ geom_path(linewidth=1.5, alpha=0.7) +
+ geom_errorbar(limits,width=.1,linewidth=.75) +
+ theme_bw(base_size = 17) +
+ scale_color_manual(values=pal) +
+ labs(x="Date", y="Cummulative Accretion (mm)")
Error: Invalid input: time_trans works with objects of class POSIXct only
>
data looks like this:
View(df)
> df
date dist mean se
1 2022-11-22 0.5 5.000000 NA
2 2023-05-18 0.5 2.333333 NA
3 2023-08-15 0.5 7.833333 4.8333333
4 2022-11-22 2 2.888889 0.9094836
5 2023-03-23 2 3.000000 NA
6 2023-05-18 2 1.000000 0.0000000
7 2023-08-15 2 6.000000 2.6943013
8 2022-11-22 6 2.500000 0.2886751
9 2023-03-23 6 3.222222 1.7462482
10 2023-05-18 6 4.333333 1.5030833
11 2023-08-15 6 9.416667 3.1983068
12 2022-11-22 12 4.750000 0.9464847
13 2023-03-23 12 6.250000 0.1595712
14 2023-05-18 12 4.833333 1.3977495
15 2023-08-15 12 10.666667 1.3608276
16 2023-03-23 18 4.333333 NA
17 2023-05-18 18 4.666667 1.0000000
18 2023-08-15 18 6.833333 3.1666667
19 2022-11-22 24 4.458333 0.8535736
20 2023-03-23 24 5.833333 0.3967460
21 2023-05-18 24 4.250000 0.8207382
22 2023-08-15 24 11.250000 2.8427132
23 2023-03-23 30 1.166667 0.1666667
24 2023-05-18 30 2.833333 1.5000000
25 2023-08-15 30 7.500000 2.5000000
26 2022-11-22 48 3.888889 0.4843221
27 2023-03-23 48 3.777778 1.2813958
28 2023-05-18 48 2.250000 1.0307764
29 2023-08-15 48 5.416667 2.0109653
I’ve tried reformatting the vector to a Date, to a POSIXct.Date, tried reimporting the data, restarting R, and sacrificing to the R gods.
Mbristow is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.