I'm trying to create a new column if character strings exist for both columns A & B of a dataframe. I thought the following would work, but its not finding characters in every cell:
df = structure(list(Participant = 1:3, A = c("char", "foo", ""), B = c("char2","", "")), .Names = c("Participant", "A", "B"), row.names = c(NA,-3L), class = "data.frame")
df$newcolumn <- ifelse(nchar(data$A)>0 && nchar(data$B)>0, "character", "nocharacter")
I'm unexpectedly getting 'nocharacter' for all rows. Anyone have suggestions on how to fix this? Thanks!