I would like to calculate sums for certain columns and then apply this summation for every row. Unfortunately, I can only get to the first step. How do I now make it happen
If you don't have NA you can apply this
suma.zscore = (zscore$a + zscore$c + zscore$t + zscore$y)
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)])