I have a data frame "books" with a numeric variable "price." I want to create a new factor variable called "affordable" with two levels: "yes" and "no." When price is greater than 100, affordable is equal to "no." When price is less than 100, affordable is equal to "yes." How do I create this variable and add it to my data frame?
This is where I'm stuck:
books$affordable <- ifelse(books$price > 100, "no", "yes")