Эта ошибка возникает только при попытке связать R Markdown с документом Word.Код работает в другом месте (в Rscript). Также у меня уже был предыдущий код, показывающий:
numericScores = transform(correctedScores, beer2_score = as.numeric(beer2_score))
numericScores = transform(correctedScores, beer3_score = as.numeric(beer3_score))
numericScores = transform(correctedScores, beer4_score = as.numeric(beer4_score))
numericScores = transform(correctedScores, beer5_score = as.numeric(beer5_score))
numericScores = transform(correctedScores, beer6_score = as.numeric(beer6_score))
# testing to see if they are indeed numeric
sapply(numericScores, mode)
correctedGuesses = Guesses[complete.cases(Guesses), ]
str(correctedGuesses)
correctedGuesses
correctedScores = numericScores[complete.cases(numericScores), ]
str(correctedScores)
correctedScores
########
# trying to put scores in correct order
# first I will label the beers with their names
for(i in 1:45){
for(j in 2:7) {
if (Order[i,j] == 1) { Order[i, j] = "Miller"}
if (Order[i,j] == 2) { Order[i, j] = "Natural"}
if (Order[i,j] == 3) { Order[i, j] = "Keystone"}
if (Order[i,j] == 4) { Order[i, j] = "Busch"}
if (Order[i,j] == 5) { Order[i, j] = "Bud"}
if (Order[i,j] == 6) { Order[i, j] = "Miller"}
}
}
# Deleting the unused/unavailable Order rows
Order = Order[-c(4, 33),]
Miller_sc = 0
Natural_sc = 0
Keystone_sc = 0
Busch_sc = 0
Bud_sc = 0
B = c(
Miller_sc,
Natural_sc,
Keystone_sc,
Busch_sc,
Bud_sc )
for (i in 1:43) {
for (j in 2:7) {
if (Order[i,j] == "Miller") {B[1] = B[1] + correctedScores[i,j]}
if (Order[i,j] == "Natural") {B[2] = B[2] + correctedScores[i,j]}
if (Order[i,j] == "Keystone") {B[3] = B[3] + correctedScores[i,j]}
if (Order[i,j] == "Busch") {B[4] = B[4] + correctedScores[i,j]}
if (Order[i,j] == "Bud") {B[5] = B[5] + correctedScores[i,j]}
}
}
Ошибка гласит:
Ошибка в B [3] + correctedScores [i, j]: нечисловой аргумент для двоичного оператора Вызовы: ... handle -> withCallingHandlers -> withVisible -> eval -> eval Выполнение остановлено