You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of our Japanese translators (@KoKYura) let me know an issue in the R code chunk below in Chapter 32 Epidemic Curves.
epi_day <- incidence( # create incidence object
x = linelist, # dataset
date_index = date_onset, # date column
interval = "day" # date grouping interval
) Error: Not implemented for class POSIXct, POSIXt
The error occurs because the date fields are imported as "POSIXct" in the previous code that uses import() function.
I was wondering if we could set the variable class as date by using readxl::read_excel() rather than import() function? Or we could convert the POSIXct variables to the date class right after the dataset is imported, using some code like this:
linelist <- import("linelist_cleaned.xlsx")
linelist[] <- lapply(linelist, function(x) {
if (inherits(x, "POSIXct")) as.Date(x) else x
})
Please let me know if I can help you with modifying the code.
Thank you,
Hitomi
The text was updated successfully, but these errors were encountered:
I believe the root issue is that this page tells the user to import the .xlsx file, instead of the cleaned .rds file with column classes intact. We chose this approach to minimize repetitive cleaning steps in every Data Visualization chapter. I must have missed this chapter!
I have fixed it in pull request #57 , with some minor change to the paragraph above as well.
If you object, please let me know, otherwise I will merge soon, and then re-render the book/website
Hi there,
One of our Japanese translators (@KoKYura) let me know an issue in the R code chunk below in Chapter 32 Epidemic Curves.
epi_day <- incidence( # create incidence object
x = linelist, # dataset
date_index = date_onset, # date column
interval = "day" # date grouping interval
)
Error: Not implemented for class POSIXct, POSIXt
The error occurs because the date fields are imported as "POSIXct" in the previous code that uses import() function.
I was wondering if we could set the variable class as date by using readxl::read_excel() rather than import() function? Or we could convert the POSIXct variables to the date class right after the dataset is imported, using some code like this:
linelist <- import("linelist_cleaned.xlsx")
linelist[] <- lapply(linelist, function(x) {
if (inherits(x, "POSIXct")) as.Date(x) else x
})
Please let me know if I can help you with modifying the code.
Thank you,
Hitomi
The text was updated successfully, but these errors were encountered: