Chunk runs in R but not in bookdown

I have the following Rmarkdown code for COVID 19 here:


    library(tidyverse)
    # Importiere Johns Hopkins Github data
    confirmedraw <- read.csv( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")
    deathsraw <- read.csv( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv")
    recoveredraw <- read.csv( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv")
    confirmed <- confirmedraw %>% 
      gather(key="date", value="confirmed", -c(Country.Region, Province.State, Lat, Long)) %>%    group_by(Country.Region, date) %>% 
      summarize(confirmed=sum(confirmed))
    deaths <- deathsraw %>% 
      gather(key="date", value="deaths", -c(Country.Region, Province.State, Lat, Long)) %>% 
      group_by(Country.Region, date) %>% 
      summarize(deaths=sum(deaths))
    recovered <- recoveredraw %>% 
      gather(key="date", value="recovered", -c(Country.Region, Province.State, Lat, Long)) %>% 
      group_by(Country.Region, date) %>% 
      summarize(recovered=sum(recovered))
    summary(confirmed)

    country <- full_join(confirmed, deaths) %>% 
      full_join(recovered)

This runs fine in RStudio preview and within the R console itself.

However, if I try to build my book with bookdown, the full_join() in the last line will fail.
I get error:

    Error: `by` must be supplied when `x` and `y` have no common variables.
    ℹ use by = character()` to perform a cross-join.
    Backtrace:
         █
      1. ├─rmarkdown::render_site(output_format = "bookdown::gitbook", encoding = "UTF-8")
      2. │ └─generator$render(...)
      3. │   ├─xfun::in_dir(...)
      4. │   └─bookdown:::render_book_script(output_format, envir, quiet)
      5. │     └─bookdown::render_book(...)
      6. │       └─bookdown:::render_cur_session(...)
      7. │         └─rmarkdown::render(main, output_format, ..., clean = clean, envir = envir)
      8. │           └─knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
      9. │             └─knitr:::process_file(text, output)
     10. │               ├─base::withCallingHandlers(...)
     11. │               ├─knitr:::process_group(group)
     12. │               └─knitr:::process_group.block(group)
     13. │                 └─knitr:::call_block(x)
     14. │                   └─knitr:::block_exec(params)
     15. │                     ├─knitr:::in_dir(...)
     16. │                     └─knitr:::evaluate(...)
     17. │                       └─evaluate::evaluate(...)
     18. │                         └─evaluate:::evaluate_call(...)
     19. │                           ├─evaluate:::timing_fn(...)
     20. │                           ├─base:::handle(...)
     21. │                           ├─base::withCallingHandlers(...)
     22. │                           ├─base::withVisible(eval(expr, envir, enclos))
     23. │                           └─base::eval(expr, envir, enclos)
     24. │                             └─base::eval(expr, envir, enclos)
     25. ├─dplyr::full_join(confirmed, deaths) %>% dplyr::full_join(., recovered)
     26. ├─dplyr::full_join(., recovered)
     27. ├─dplyr::full_join(confirmed, deaths)
     28. └─dplyr:::full_join.data.frame(confirmed, deaths)
     29.   └─dplyr:::join_mutate(...)
     30.     └─dplyr:::join_cols(...)
     31.       └─dplyr:::standardise_join_by(by, x_names = x_names, y_names = y_names)

How would I change my code to run with bookdown?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.