my dataframe contains 784,081 firms * 13 years = 10,193,053 unique firm_year observations (e.g. firm1_2007, firm1_2008,firm1_2009, ......, ......, firm784,081 2018, firm784,081 2019 ) from 12 home countries.
Now, I want to insert a column "gdpgrowthpercapita". I have 13 * 12=156 unique values (decimals, e.g. 3.34587) depending on year and homecountry to insert.
-
First, I tried to nest ifelse() statements. This works in general, however, there is a limit of 50 nested statements; everything >50 does not work (see here: Is there a limit for the possible number of nested ifelse statements)
-
Next, I attempted to code "blocks" of ifelse() statemens for every country; however, the problem is that the no argument in ifelse(test, yes, no) cannot be neglected, or - to my knowledge - set in a way that it does not touch the fields where test does not apply.
How can I code my variable?
I am thankful for help! Hopefully, there is an obvious way I missed - as an R Rookie.
Thank you in advance!
Best, Mo
Aucun commentaire:
Enregistrer un commentaire