Building on this questions:
R dplyr mutate on column index
dplyr: how to reference columns by column index rather than column name using mutate?
I want to mutate several columns using column indexes for both the source and the destination of the mutate like:
df <- tribble(~C1,~C2,~C3,1,2,3,4,5,6,7,8,9)
dfn <- df
dfn[,1:2] = dfn[,3] # like this in dplyr
df <- df %>% mutate(accross(.[[1:2]]) = .[[3]])
gives:
Fehler: Unerwartete(s) '=' in "df <- df %>% mutate(accross(.[[1:2]]) ="
Error: Unexpected '=' in "df <- df %>% mutate(accross(.[[1:2]]) ="