sum cells of certain columns for each row
The summation of all individual rows can also be done using the row-wise operations of dplyr (with col1, col2, col3
defining three selected columns for which the row-wise sum is calculated):
library(tidyverse)
df <- df %>%
rowwise() %>%
mutate(rowsum = sum(c(col1, col2,col3)))
You could do something like this:
summed <- rowSums(zscore[, c(1, 2, 3, 5)])