Yesterday I wrote a syntax for R using the following:
attach(stage)
eleven$stage[stadpt == 6 & stadpn == 0 & stadpm == 0] <-0
I have a data frame with merged data frames and everything worked very well. However today I did exactly the same with an addition:
attach(stage)
eleven$stage[locprim < 9 & stadpt == 6 & stadpn == 0 & stadpm == 0] <-0
But now it doesn't work.. I now get errors that it doesn't recognize the variables anymore
> attach(stage)
Error in attach(stage) : object 'stage' not found
> eleven$stage[locprim < 9 & stadpt == 6 & stadpn == 0 & stadpm == 0] <-0
Error in eleven$stage[locprim < 9 & stadpt == 6 & stadpn == 0 & stadpm == :
object 'locprim' not found
I know I can solve this by entering eleven$
before every variable (and leave out attach(stage)
)but it doesn't make sense (and I have a very long code so I would have to do this suddenly a lot of times..). Yesterday it worked perfectly.
Do you have any idea why this is the case?
Thank you a lot in advance!!
Best wishes, Anne