Я использую следующие строки кода для создания новой переменной из других переменных:
FER_TMS_nopractice_recoded_replaced %>% select(FACE.RT, SCRAM1.RT_total, SCRAM2.RT_total, SCRAM3.RT_total,
SCRAM4.RT_total, SCRAM5.RT_total, SCRAM6.RT_total, SCRAM7.RT_total, SCRAM8.RT_total,
SCRAM9.RT_total, SCRAM10.RT_total, SCRAM11.RT_total, SCRAM12.RT_total, RESPOND.RT_total,
WHITE4.RT_total) %>% rowSums(na.rm = TRUE) -> FER_TMS_nopractice_recoded_replaced$RT_TOTAL
Проблема в том, что, хотя для некоторых столбцов она работает нормально, для других я получаю следующую ошибку: Ошибка в FACE.RESP + RESPOND.RESP: non-Numberri c аргумент бинарного оператора
Все столбцы / переменные содержат значения NA, и я не понимаю, почему код выполняется для некоторых, а не для других переменных. Есть предложения по исправлению?
Структура данных:
structure(list(SessionDate = structure(c(1L, 1L, 1L), .Label = c("07-16-2019",
"07-23-2019", "07-30-2019"), class = "factor"), SessionTime = structure(c(1L,
1L, 1L), .Label = c("11:46:03", "12:09:32", "13:12:03", "13:36:15",
"17:01:32", "17:28:27"), class = "factor"), Subject = c(3L, 3L,
3L), Sex = structure(c(1L, 1L, 1L), .Label = "male", class = "factor"),
Age = c(23L, 23L, 23L), Handedness = structure(c(1L, 1L,
1L), .Label = "right", class = "factor"), preOrpost = c("PRE",
"PRE", "PRE"), Site = c("RIGHT", "RIGHT", "RIGHT"), Condition = structure(c(2L,
2L, 2L), .Label = c("EMOPRAC", "EMOstim", "GENDPRAC", "GENDstim"
), class = "factor"), Duration = c(300L, 40L, 40L), Correct = c(2L,
2L, 1L), FACE.RESP = c("1", "1", "1"), SCRAM1.RESP = c(NA,
NA, NA), SCRAM2.RESP = c(NA, NA, NA), SCRAM3.RESP = c(NA,
NA, NA), SCRAM4.RESP = c(NA, NA, NA), SCRAM5.RESP = c(NA,
NA, NA), SCRAM6.RESP = c(NA, NA, NA), SCRAM7.RESP = c(NA,
NA, NA), SCRAM8.RESP = c(NA_character_, NA_character_, NA_character_
), SCRAM9.RESP = c(NA_character_, NA_character_, NA_character_
), SCRAM10.RESP = c(NA_character_, NA_character_, NA_character_
), SCRAM11.RESP = c(NA_character_, NA_character_, NA_character_
), SCRAM12.RESP = c(NA_character_, NA_character_, NA_character_
), RESPOND.ACC = c(1L, 0L, 1L), RESPOND.RESP = c("1", "0",
"1"), WHITE4.RESP = c(NA, NA, NA), FACE.RT = c(NA_integer_,
NA_integer_, NA_integer_), SCRAM1.RT = c(NA_integer_, NA_integer_,
NA_integer_), SCRAM2.RT = c(NA_integer_, NA_integer_, NA_integer_
), SCRAM3.RT = c(NA_integer_, NA_integer_, NA_integer_),
SCRAM4.RT = c(NA_integer_, NA_integer_, NA_integer_), SCRAM5.RT = c(NA_integer_,
NA_integer_, NA_integer_), SCRAM6.RT = c(NA_integer_, NA_integer_,
NA_integer_), SCRAM7.RT = c(NA_integer_, NA_integer_, NA_integer_
), SCRAM8.RT = c(NA_integer_, NA_integer_, NA_integer_),
SCRAM9.RT = c(NA_integer_, NA_integer_, NA_integer_), SCRAM10.RT = c(NA_integer_,
NA_integer_, NA_integer_), SCRAM11.RT = c(NA_integer_, NA_integer_,
NA_integer_), SCRAM12.RT = c(NA_integer_, NA_integer_, NA_integer_
), RESPOND.RT = c(251L, 1111L, 426L), WHITE4.RT = c(NA_integer_,
NA_integer_, NA_integer_)), row.names = c(NA, 3L), class = "data.frame")