The following code creates the variables A and B which hold the number-transformed text values from VariableA and VariableB. It then computes the means of A and B, and ranks those means.
#-----------------------------
tempdata = data
library(dplyr)
#-----------------------------
# For when you need to do calculations
# on each row separately:
tempdata = mutate(rowwise(tempdata),
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)
)
# For when you need to do a calculation
# on one column across all the rows:
tempdata = mutate(ungroup(tempdata),
RankedMeanScore = rank(MeanScore,
na.last = "keep",
ties.method = "average")
)
#-----------------------------
data = cbind(data,tempdata)
#-----------------------------