I think this was asked already before, but I cannot find a solution for my issue. I have the following data frame
(obj_1 <- data.frame (
yr = c(1990, 1990, 1990, 1992, 1992, 1992),
EARNWEEK= c(223, 200, 234, 500, 700, 800),
AHRSWORKT= c(50, 40, 35, 35, 35, 40),
WAGE = c(10, 8, 8, 9, 10, 9)
))
I would like created a column named REALWAGE, where I insert in each row the value of the variable WAGE multiplied by a value, which differs across the years. As I try to run the following code ...
obj_1[obj_1$yr %in% 1992,"REALWAGE"] <- obj_1$WAGE*1.223
and so on for the next year
obj_1[obj_1$yr %in% 1993,"REALWAGE"] <- obj_1$WAGE*1.153
... the error replacement has 45781858 rows, data has 1752611
is getting displayed. How is it possible to fix that?
Many thanks in advance!!