I am new to using R and I am encountering a really annoying roadblock.
I am trying to use a dataset and convert all 0's to a value of "Not_Eaten' and all 1's to a value of Eaten.
I am using this statement
attach(data)
Eaten <- ifelse(Eaten==0, "Not_Eaten",'Eaten')
but the datasheet does not update and the Eaten column is still populated with 0's and 1's.
Can someone please point out what I am doing wrong here?
If it helps, the class is integer and not numeric for some reason.
CodePudding user response:
Use:
data$Eaten <- ifelse(data$Eaten == 0, "Not_Eaten", 'Eaten')
Or:
data$Eaten <- ifelse(data['Eaten'] == 0, "Not_Eaten", 'Eaten')