#-------------------------------------------------------------------------------------------------------
tempdata = data
library(dplyr)
#-------------------------------------------------------------------------------------------------------
tempdata =
mutate(rowwise(tempdata), # {for when you need to do calculations for each row separately}
# mutate(tempdata, # {for when you need to do a calculation on one column, across all the rows}
A = case_when(
VariableA == "one" ~ 1.0,
VariableA == "two" ~ 2.0,
VariableA == "three" ~ 3.0
)
,
B = case_when(
VariableB == "one" ~ 1.0,
VariableB == "two" ~ 2.0,
VariableB == "three" ~ 3.0
)
,
MeanScore = mean(c(A,B), na.rm = TRUE)
)
#-------------------------------------------------------------------------------------------------------
tempdata =
# mutate(rowwise(tempdata), # {for when you need to do calculations for each row separately}
mutate(tempdata, # {for when you need to do a calculation on one column, across all the rows}
RankedMeanScore(MeanScore, na.last = "keep", ties.method = "average")
)
#-------------------------------------------------------------------------------------------------------
data = cbind(data,tempdata)
#-------------------------------------------------------------------------------------------------------