Reputation: 17
Make a new column that is binary based on if chance.of.admit > 0.5
chance.of.admit is a variable in the data frame
Would I need to loop over chance? How would I go about looping over change and adding a new column with 1's and 0's? Is there a better way?
Upvotes: 0
Views: 41
Reputation: 103
Another solution is:
df$binary <- ifelse(df$chance.of.admit>0.5, 1, 0)
Upvotes: 1