I followed this code to create the row total for the dataframe df
library(tidyverse)
df <- df %>%
bind_rows(summarise(., across(where(is.numeric), sum),
across(where(is.character), ~'Total')))
If I modified the code, it would return an error
df <- df %>%
bind_rows(summarise(across(where(is.numeric), sum),
across(where(is.character), ~'Total')))
# Error: `across()` must only be used inside dplyr verbs.
My question is: what does the dot .
inside the summarise
refer to? Why was it needed for the code to run properly? My guess was that the dot referred to the dataframe df
, which was already implied by the part df %>%
. This post didn't answer my question.