I'm sorry if variables will not be displayed as usually, but I'm new at this...
I'm trying to create a stacked barchart using ggplot2 and I've made almost everything so far except plot it on DD-MM-YYYY format. I've been able to plot the chart on Julian Day using
ggplot(DataFrame, aes(fill=GroupVariable, y=YVar, x=JulianDay))
but every time I try something to change it to DD-MM-YYYY format it returns "Error in as.Date.numeric(value) : 'origin' must be supplied". I've also tried to set the origin to 1970-01-01 but it returns the same error message. Bellow I present some different attempts I've made:
ggplot(DataFrame, aes(fill=GroupVariable, y=YVar, x=as.Date(JulianDay, origin=as.Date("1970-01-01"))))
using lubridate:
ggplot(DataFrame, aes(fill=GroupVariable, y=YVar, x=ymd(Time_variable_in_YYYYMMDD_format)))
using epitools:
ggplot(DataFrame, aes(fill=GroupVariable, y=YVar, x=julian2date(JulianDay, origin=as.Date("1970-01-01"))))
I do not want to plot it by turning the date into factor because then the graphs will loose the time scale and the data is not evenly spaced.
As asked, I present an example of my data frame bellow
Value | Group | Date | Date_Julian1900 | Date_Julian1970 |
---|---|---|---|---|
0.002683715 | A | 2018-05-07 | 43227.00 | 17658.00 |
0.363345653 | A | 2018-06-06 | 43257.00 | 17688.00 |
0.211011887 | A | 2018-07-04 | 43285.00 | 17716.00 |
0.699667394 | A | 2018-08-06 | 43318.00 | 17749.00 |
0.080374412 | A | 2018-09-05 | 43348.00 | 17779.00 |
0.186650813 | A | 2018-10-02 | 43375.00 | 17806.00 |
0.030873721 | A | 2018-10-31 | 43404.00 | 17835.00 |
0.057359736 | A | 2018-11-30 | 43434.00 | 17865.00 |
0.000583098 | A | 2019-01-03 | 43468.00 | 17899.00 |
0 | A | 2019-01-29 | 43494.00 | 17925.00 |
0 | A | 2019-03-27 | 43551.00 | 17982.00 |
0 | A | 2018-05-17 | 43237.00 | 17668.00 |
0.138461307 | A | 2018-07-13 | 43294.00 | 17725.00 |
0.274086982 | A | 2018-08-10 | 43322.00 | 17753.00 |
0.145111397 | A | 2018-09-09 | 43352.00 | 17783.00 |
0.33842957 | B | 2018-05-07 | 43227.00 | 17658.00 |
0.32761246 | B | 2018-06-06 | 43257.00 | 17688.00 |
0.414862573 | B | 2018-07-04 | 43285.00 | 17716.00 |
0.172168493 | B | 2018-08-06 | 43318.00 | 17749.00 |
0.156903282 | B | 2018-09-05 | 43348.00 | 17779.00 |
0.203908458 | B | 2018-10-02 | 43375.00 | 17806.00 |
0.120373644 | B | 2018-10-31 | 43404.00 | 17835.00 |
0.101954311 | B | 2018-11-30 | 43434.00 | 17865.00 |
0.11928644 | B | 2019-01-03 | 43468.00 | 17899.00 |
0.03338635 | B | 2019-01-29 | 43494.00 | 17925.00 |
0.1703545 | B | 2019-03-27 | 43551.00 | 17982.00 |
0.019091472 | B | 2018-05-17 | 43237.00 | 17668.00 |
0.369557828 | B | 2018-07-13 | 43294.00 | 17725.00 |
0.12126825 | B | 2018-08-10 | 43322.00 | 17753.00 |
0.133006126 | B | 2018-09-09 | 43352.00 | 17783.00 |
0.070069201 | C | 2018-05-07 | 43227.00 | 17658.00 |
0.115976922 | C | 2018-06-06 | 43257.00 | 17688.00 |
0.096136808 | C | 2018-07-04 | 43285.00 | 17716.00 |
0.026000904 | C | 2018-08-06 | 43318.00 | 17749.00 |
0.063052453 | C | 2018-09-05 | 43348.00 | 17779.00 |
0.067014627 | C | 2018-10-02 | 43375.00 | 17806.00 |
0.868220389 | C | 2018-10-31 | 43404.00 | 17835.00 |
0.063531995 | C | 2018-11-30 | 43434.00 | 17865.00 |
0.043645255 | C | 2019-01-03 | 43468.00 | 17899.00 |
0.023917014 | C | 2019-01-29 | 43494.00 | 17925.00 |
0 | C | 2019-03-27 | 43551.00 | 17982.00 |
0.003265612 | C | 2018-05-17 | 43237.00 | 17668.00 |
0.132452726 | C | 2018-07-13 | 43294.00 | 17725.00 |
0.035795901 | C | 2018-08-10 | 43322.00 | 17753.00 |
0.067606397 | C | 2018-09-09 | 43352.00 | 17783.00 |