]1
I have datas that look like the excel table shown in the screen capture and I want to plot it like the picture called meff_exemple. Someone wrote me the following script but it does not work...
dat <- readxl::read_xlsx( "/Users/XX/Desktop/XXX.xlsx" ) |>
janitor::clean_names()
dat |>
mutate(meff = str_replace_all(meff, "not calculated", "NA")) |>
mutate(meff = as.numeric(meff)) |>
ggplot(aes(year, meff)) +
geom_col(aes(fill = land_type), position = "dodge") +
facet_wrap(~place) + theme_light(base_size = 6)
ggsave( filename = "lcc_graph_example.png", plot = last_plot(),
width = 6, height = 3, device = "png", dpi = 300 )
Error in `mutate()`: ! Problem while computing `meff =
str_replace_all(meff, "not calculated", "NA")`. Caused by error in
`stri_replace_all_regex()`: ! object 'meff' not found Run
`rlang::last_error()` to see where the error occurred.
> ggsave(
+ filename = "lcc_graph_example.png",
+ plot = last_plot(), width = 6, height = 3, device = "png", dpi = 300
+ )
> rlang::last_error() <error/dplyr:::mutate_error> Error in `mutate()`: ! Problem while computing `meff = str_replace_all(meff,
"not calculated", "NA")`. Caused by error in
`stri_replace_all_regex()`: ! object 'meff' not found
--- Backtrace:
1. ggplot2::ggplot(...)
8. stringr::str_replace_all(meff, "not calculated", "NA")
9. stringi::stri_replace_all_regex(...) Run `rlang::last_trace()` to see the full context.