I am trying to add a new column to a data frame as follows:
stateFrame$cgroup <- ifelse(stateFrame$Freq >= 11 &
stateFrame$Freq < 83, "Other",stateFrame$city)
So, I want if the value of frequency in the row is between 11 and 83, the new column must be assigned Other
, else it should keep the same value as exists in another column city
(stateFrame$city)
.
It works fine for adding value as other
but for all other cases, a row number corresponding to the data frame is assigned as shown below:
What could be the reason for this? Am I missing anything?