I have a following problem. I have two dataframes (df1 and df2) and I want to calculate a mean of them. I read data from xls, so I show you a print screen of my dataframe, because I don`t know how to name columns "1.", "2." etc.
I use this code:
df_together <- bind_rows(df1 %>% add_rownames(),
df2 %>% add_rownames()) %>%
# evaluate following calls for each value in the rowname column
group_by(rowname) %>%
# mean
summarise_all(mean)
This code worked a year ago, but know I get this error message. I don`t know, what this error means:
<error/rlang_error>
Obsolete data mask.
x Too late to resolve `měsíc` after the end of `dplyr::summarise()`.
i Did you save an object that uses `měsíc` lazily in a column in the `dplyr::summarise()` expression ?
Backtrace:
x
1. +-`%>%`(...)
2. \-dplyr::summarise_all(., mean)
3. +-dplyr::summarise(.tbl, !!!funs)
4. \-dplyr:::summarise.grouped_df(.tbl, !!!funs)
5. \-dplyr:::summarise_cols(.data, ...)
6. \-mask$forget("summarise")
7. +-base::suppressWarnings(...)
8. | \-base::withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
9. +-rlang::env_bind_lazy(bindings, !!!set_names(promises, names_bindings))
10. \-dplyr:::osbolete_promise_fn("mesíc")
How can I fix it please? This did not help me: Obsolete data mask. Too late to resolve `xxxxxx` after the end of `dplyr::mutate()`
dplyr
1.0.4`bind_rows(mtcars %>% add_rownames(), mtcars %>% add_rownames()) %>% group_by(rowname) %>% summarise_all(mean)
But, there is a recommendation to usetibble::rownames_to_column()
andsummarise(across(everything(), mean))
– akrunrownames_to_column
orsummarise(across
– akruns the
summarise(across(everything(), mean))` – vojtam