Reputation: 71
I have a data frame as "tab1" having name and salary ,now i am trying to create a new table as "tab2" with bonus based on their salary in tab1,i am getting error as " object 'tab2' not found ". below is my code
tab2$bonus <- ifelse(tab1$salary < 1000, 0.5, tab1$salary)
How to resolve it ,thanks in advance
Upvotes: 0
Views: 35
Reputation: 887078
We need to create a tab2
object before doing tab2$bonus
. Assuming that the OP wanted 'tab2' as a data.frame,
tab2 <- data.frame(bonus = ifelse(tab1$salary< 1000 ,
0.5 ,tab1$salary))
Upvotes: 1