How to add a factor column to dataframe based on a conditional statement from another column?

you can use ifelse like this

dataframe$periodframe <- ifelse(dataframe$year > 1991,"post-1991", "pre-1991")

Leave a Comment