Reputation: 41
I have a table with 8 variables, one of them is a factor with 3 levels. I want to write something in a new column based on which of the the levels but can't figure it out.
if(Nitro[Nitro$Result == "push", ]){
Nitro$Profit <- 0
}
Upvotes: 0
Views: 36
Reputation: 3621
If you are using data frames, this should work.
Nitro$Profit[Nitro$Result == "push"] <- 0
If you are using data table, try:
Nitro[Result == "push", Profit := 0]
Upvotes: 2