Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Chapter 32 Epidemic Curve #56

Open
hitomik723 opened this issue Oct 17, 2021 · 2 comments
Open

Error in Chapter 32 Epidemic Curve #56

hitomik723 opened this issue Oct 17, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@hitomik723
Copy link

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

@aspina7 aspina7 added this to To do in EpiRhandbook content revisions via automation Oct 17, 2021
@aspina7 aspina7 added this to To do in EpiRhandbook translations via automation Oct 17, 2021
@aspina7 aspina7 added the bug Something isn't working label Oct 17, 2021
@nsbatra
Copy link
Contributor

nsbatra commented Oct 17, 2021

@hitomik723 and @KoKYura, thank you for identifying this error!

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

@hitomik723
Copy link
Author

Your edits look good. Thank you for your prompt response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants