I'm working on a report to upload to the 'kaggle' platform and I've run into a problem that I can't solve.
# Load packages
library(tidyverse)
library(janitor)
library(bit64)
library(highcharter)
# Load datasets
country_vaccinations <- read.csv('../input/covid-world-vaccination-progress/country_vaccinations.csv')
country_vaccinations_by_manufacturer <- read.csv('../input/covid-world-vaccination-progress/country_vaccinations_by_manufacturer.csv')
# I create a variable with the correct formats
country_vaccinations.formatted <- country_vaccinations %>%
mutate(date = as.Date(date),
total_vaccinations = as.integer64(total_vaccinations)) %>%
mutate_at(c('people_vaccinated',
'daily_vaccinations_raw',
'daily_vaccinations',
'daily_vaccinations_per_million'), as.integer)
# country_vaccinations_by_manufacturer:
# I create a variable with the correct formats
country_vaccinations_by_manufacturer.formatted <- country_vaccinations_by_manufacturer %>%
mutate(date = as.Date(date))
# How many immunizations were administered in the world to date?
immunizations_applied <- country_vaccinations.formatted %>%
summarise(total_immunizations = sum(total_vaccinations, na.rm = TRUE))
immunizations_applied
# How many immunizations were administered in each country?
immunizations_applied_country <- country_vaccinations.formatted %>%
group_by(country, iso_code) %>%
summarise(total_immunizations = sum(total_vaccinations, na.rm = TRUE), .groups = 'drop') %>%
arrange(desc(total_immunizations))
head(immunizations_applied_country)
# Creation of the graph where the amount of immunizations applied by each country is represented
hc_my_theme <- hc_theme_merge(hc_theme_flatdark(),
hc_theme(chart = list(backgroundColor = '#242f39'),
subtitle = list(style = list(color = '#a7a5a5'))))
plot_immunizations_applied_country <- hcmap(map = 'custom/world-robinson-lowres',
data = immunizations_applied_country,
joinBy = c('iso-a3', 'iso_code'),
value = 'total_immunizations',
name = 'Immunizations in:',
borderWidth = 0,
nullColor = "#d3d3d3") %>%
hc_title(text = 'Immunizations applied per country') %>%
hc_subtitle(text ='How many applied immunizations does each country have?') %>%
hc_colorAxis(
stops = color_stops(colors = viridisLite::inferno(10, begin = 0.1)),
type = "logarithmic") %>%
hc_add_theme(hc_my_theme) %>%
hc_mapNavigation(enabled = TRUE) %>%
hc_credits(enabled = FALSE) %>%
hc_exporting(enabled = TRUE)
plot_immunizations_applied_country
The problem arises when wanting to make the graph:
Error: parse error: trailing garbage
[6651,7931],[6704,7922]]]}}]};
(right here) ------^
Traceback:
1. hcmap(map = "custom/world-robinson-lowres", data = immunizations_applied_country,
. joinBy = c("iso-a3", "iso_code"), value = "total_immunizations",
. name = "Immunizations in:", borderWidth = 0, nullColor = "#d3d3d3") %>%
. hc_title(text = "Immunizations applied per country") %>%
. hc_subtitle(text = "How many applied immunizations does each country have?") %>%
. hc_colorAxis(stops = color_stops(colors = viridisLite::inferno(10,
. begin = 0.1)), type = "logarithmic") %>% hc_add_theme(hc_my_theme) %>%
. hc_mapNavigation(enabled = TRUE) %>% hc_credits(enabled = FALSE) %>%
. hc_exporting(enabled = TRUE)
2. hc_exporting(., enabled = TRUE)
3. .hc_opt(hc, "exporting", ...)
4. assertthat::assert_that(is.highchart(hc))
5. see_if(..., env = env, msg = msg)
6. tryCatch({
. eval(assertion, env)
. }, assertError = function(e) {
. structure(FALSE, msg = e$message)
. })
7. tryCatchList(expr, classes, parentenv, handlers)
8. tryCatchOne(expr, names, parentenv, handlers[[1L]])
9. doTryCatch(return(expr), name, parentenv, handler)
10. eval(assertion, env)
11. eval(assertion, env)
12. is.highchart(hc)
13. hc_credits(., enabled = FALSE)
14. .hc_opt(hc, "credits", ...)
15. assertthat::assert_that(is.highchart(hc))
16. see_if(..., env = env, msg = msg)
17. tryCatch({
. eval(assertion, env)
. }, assertError = function(e) {
. structure(FALSE, msg = e$message)
. })
18. tryCatchList(expr, classes, parentenv, handlers)
19. tryCatchOne(expr, names, parentenv, handlers[[1L]])
20. doTryCatch(return(expr), name, parentenv, handler)
21. eval(assertion, env)
22. eval(assertion, env)
23. is.highchart(hc)
24. hc_mapNavigation(., enabled = TRUE)
25. .hc_opt(hc, "mapNavigation", ...)
26. assertthat::assert_that(is.highchart(hc))
27. see_if(..., env = env, msg = msg)
28. tryCatch({
. eval(assertion, env)
. }, assertError = function(e) {
. structure(FALSE, msg = e$message)
. })
29. tryCatchList(expr, classes, parentenv, handlers)
30. tryCatchOne(expr, names, parentenv, handlers[[1L]])
31. doTryCatch(return(expr), name, parentenv, handler)
32. eval(assertion, env)
33. eval(assertion, env)
34. is.highchart(hc)
35. hc_add_theme(., hc_my_theme)
36. assert_that(is.highchart(hc), .is_hc_theme(hc_thm))
37. see_if(..., env = env, msg = msg)
38. tryCatch({
. eval(assertion, env)
. }, assertError = function(e) {
. structure(FALSE, msg = e$message)
. })
39. tryCatchList(expr, classes, parentenv, handlers)
40. tryCatchOne(expr, names, parentenv, handlers[[1L]])
41. doTryCatch(return(expr), name, parentenv, handler)
42. eval(assertion, env)
43. eval(assertion, env)
44. is.highchart(hc)
45. hc_colorAxis(., stops = color_stops(colors = viridisLite::inferno(10,
. begin = 0.1)), type = "logarithmic")
46. .hc_opt(hc, "colorAxis", ...)
47. assertthat::assert_that(is.highchart(hc))
48. see_if(..., env = env, msg = msg)
49. tryCatch({
. eval(assertion, env)
. }, assertError = function(e) {
. structure(FALSE, msg = e$message)
. })
50. tryCatchList(expr, classes, parentenv, handlers)
51. tryCatchOne(expr, names, parentenv, handlers[[1L]])
52. doTryCatch(return(expr), name, parentenv, handler)
53. eval(assertion, env)
54. eval(assertion, env)
55. is.highchart(hc)
56. hc_subtitle(., text = "How many applied immunizations does each country have?")
57. .hc_opt(hc, "subtitle", ...)
58. assertthat::assert_that(is.highchart(hc))
59. see_if(..., env = env, msg = msg)
60. tryCatch({
. eval(assertion, env)
. }, assertError = function(e) {
. structure(FALSE, msg = e$message)
. })
61. tryCatchList(expr, classes, parentenv, handlers)
62. tryCatchOne(expr, names, parentenv, handlers[[1L]])
63. doTryCatch(return(expr), name, parentenv, handler)
64. eval(assertion, env)
65. eval(assertion, env)
66. is.highchart(hc)
67. hc_title(., text = "Immunizations applied per country")
68. .hc_opt(hc, "title", ...)
69. assertthat::assert_that(is.highchart(hc))
70. see_if(..., env = env, msg = msg)
71. tryCatch({
. eval(assertion, env)
. }, assertError = function(e) {
. structure(FALSE, msg = e$message)
. })
72. tryCatchList(expr, classes, parentenv, handlers)
73. tryCatchOne(expr, names, parentenv, handlers[[1L]])
74. doTryCatch(return(expr), name, parentenv, handler)
75. eval(assertion, env)
76. eval(assertion, env)
77. is.highchart(hc)
78. hcmap(map = "custom/world-robinson-lowres", data = immunizations_applied_country,
. joinBy = c("iso-a3", "iso_code"), value = "total_immunizations",
. name = "Immunizations in:", borderWidth = 0, nullColor = "#d3d3d3")
79. download_map_data(map)
80. jsonlite::fromJSON(mapdata, simplifyVector = FALSE)
81. parse_and_simplify(txt = txt, simplifyVector = simplifyVector,
. simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix,
. flatten = flatten, ...)
82. parseJSON(txt, bigint_as_char)
83. parse_string(txt, bigint_as_char)
I only have the problem when I try to publish the notebook to kaggle. Using RStudio I have no problem. Thank you very much in advance and I hope to find a solution.