0

I'm trying to create a unique variable which corresponds to companies in a panel dataset. I'm using R.

Currently the data looks like this:

investor year activity location
123 IM 2002 4.45 France
123 IM 2003 3.2 France
123 IM 2004 7.8 France
Aegon 2005 5.4 Netherlands
Aegon 2006 4.2 Netherlands
Aegon 2007 1.3 Netherlands

I would like to create a new column so the dataframe looks like this:

investor investorid year activity location
123 IM 1 2002 4.45 France
123 IM 1 2003 3.2 France
123 IM 1 2004 7.8 France
Aegon 2 2005 5.4 Netherlands
Aegon 2 2006 4.2 Netherlands
Aegon 2 2007 1.3 Netherlands

The exact location of the column doesn't really matter, I just put it next to the investor name in this example.

I expect I need to use grouby(investor) then mutate a new column?

Cheers!

R Wd
  • 59
  • 5

0 Answers0