I have a dataframe consisting of two samples. Only one sample has answered a questionnaire about state anxiety. For this case, I have calculated a vector for somatic state anxiety with the following function "rowSums":
som_lp <- rowSums(sample1[,c(1, 7, 8, 10 )+108], na.rm = TRUE)
Now I would like to add this to my existing dataframe "data", but the function "cbind" doesn't work here, because of the different lengths (dataframe 88, som_lp 59).
data <- cbind(data, som_lp)
Can anyone help me and is there another option to calculate "som_lp" to avoid the different lengths?
We can use cbind.fill
from rowr
library(rowr)
cbind.fill(data, som_lp, fill = NA)