Итак, в моем большом документе с уценкой у меня есть карта, которая раньше работала нормально, но теперь выдает ошибку, для которой я не могу найти никаких исправлений. Если я запускаю фрагмент карты отдельно, он работает нормально - просто если я свяжу весь документ.
Ошибка:
Error: Assigned data `0` must be compatible with existing data.
i Error occurred for column `CountryName`.
x Can't convert <double> to <character>.
Backtrace:
x
1. +-rmarkdown::render(...)
2. | \-knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
3. | \-knitr:::process_file(text, output)
4. | +-base::withCallingHandlers(...)
5. | +-knitr:::process_group(group)
6. | \-knitr:::process_group.block(group)
7. | \-knitr:::call_block(x)
8. | \-knitr:::block_exec(params)
9. | +-knitr:::in_dir(...)
10. | \-knitr:::evaluate(...)
11. | \-evaluate::evaluate(...)
12. | \-evaluate:::evaluate_call(...)
13. | +-evaluate:::timing_fn(...)
14. | +-base:::handle(...)
15. | +-base::withCallingHandlers(...)
16. | +-base::withVisible(eval(expr, envir, enclos))
17. | \-base::eval(expr, envir, enclos)
18. |
Execution halted
Код для фрагмента:
contacts <- read_csv("location.csv", col_names = TRUE)
locations <- read_csv("locations.csv", col_names = TRUE)
locations <- locations %>%
mutate_geocode(Location, force = TRUE)
contacts <- left_join(contacts, locations, by = "Location")
countries <- geojson_read("countries.geojson", what = "sp")
labelsmap <- sprintf("<strong>%s<strong><br/>Null families = %d<br/>Missense families = %d<br/>Unknown families = %d<br/>Null carriers = %d<br/>Missense carriers = %d<br/>Unknown carriers = %d",
countries$ADMIN,
countries$Families_Null,
countries$Families_Missense,
countries$Families_Unknown,
countries$Carriers_Null,
countries$Carriers_Missense,
countries$Carriers_Unknown) %>%
lapply(HTML)
bins <- c(0, 1, 5, 10, 15, 20, 50, 100, 150, 200)
pal <- colorBin("YlOrRd", domain = countries$Carriers_Null, bins = bins)
map <- leaflet(countries) %>%
addTiles() %>%
addMarkers(lng = contacts$lon, lat = contacts$lat, clusterOptions = markerClusterOptions(), label = paste0(contacts$Contact, " - ", contacts$Location)) %>%
addResetMapButton() %>%
addSearchOSM() %>%
addPolygons(
fillColor = ~pal(Carriers_Null),
color = "black",
dashArray = "3",
weight = 1,
opacity = 1,
label = labelsmap,
highlight = highlightOptions(
weight = 5,
bringToFront = TRUE
)) %>%
addLegend(pal = pal, values = ~Carriers_Null, opacity = 0.7, title = "Null carriers", position = "bottomright") %>%
fitBounds(lng1 = min(contacts$lon),
lat1 = min(contacts$lat),
lng2 = max(contacts$lon),
lat2 = max(contacts$lat))
map
У кого-нибудь есть опыт работы с этой ошибкой или понимает, почему она ломается только при вязании документа?