KasperSkytte / ampvis2

Tools for visualising microbial community amplicon data
https://kasperskytte.github.io/ampvis2/
GNU General Public License v3.0
67 stars 24 forks source link

amp_timeseries does not support the format argument #131

Closed bernt-matthias closed 2 years ago

bernt-matthias commented 2 years ago

If I use the format argument for the amp_timeseries function I get

Error in .local(x, ...) : unused arguments (format = "%Y")

Seems that lubridate::as_date no longer supports this (https://github.com/tidyverse/lubridate/issues/607)

KasperSkytte commented 2 years ago

Hmm works fine here

library(ampvis2)
#> Loading required package: ggplot2
AalborgWWTPs$metadata$Date <- as.character(AalborgWWTPs$metadata$Date)
amp_timeseries(AalborgWWTPs, time_variable = "Date", format = "%Y-%m-%d", group_by = "Plant")
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union

Created on 2022-01-05 by the reprex package (v2.0.1)

bernt-matthias commented 2 years ago

I loaded the time columns as factors .. remember that I read somewhere that time columns should be loaded as character / factor. You can reproduce the error (if it is one) with:

library(ampvis2)
AalborgWWTPs$metadata$Date <- as.factor(AalborgWWTPs$metadata$Date)
amp_timeseries(AalborgWWTPs, time_variable = "Date", format = "%Y-%m-%d", group_by = "Plant")
KasperSkytte commented 2 years ago

I'll close this. Dates are just pesky. It's best if the particular column is already a properly formatted date class before loading the data. The ... passed to lubridate::as_date is just there for an extra convenience.