I have a column with multiple response values. Answers look like "1,2,3" and "1,4,5" for example. I have successfully created binary columns that tell me if a number is present in the character string listed in the column.
Right now: I have 0 values for the entire subsequent columns when there is no response in my main column.
I want there to be all NA values when there is nothing in my main column. My code right now changes all the values in the subsequent column to NA.
Here is my code right now:
if(data$main== "") {
data[c(which(colnames(data)=="One"):which(colnames(data)=="Five"))] = NA
}