I have a dataframe "employee" like this:
Emp_Id,Name,Dept_Id
20203,Sam,1
20301,Rodd,2
30321,Mike,3
40403,Derik,4
Now i want to transform this dataframe in a way that the Dept_Id have department names instead of Dept_Id.
I am trying to use recode from dplyrfor this, since my transformation logic comes from a csv, I would have to use a variable in place of transformation logic.
I used read.csv to get my dataframe df where my logic (1=HR,2=IT and so on) sits and then get it in a list:
df:
Source,Target,Transformation
Employee,Emp,"1=HR,2=Sales,3=Finance,4=IT"
To get the transaformation login from df
myList <- as.character(df[1,3])
Now replacing the data in employee as per the logic
employee$Dept_Id <- recode(employee$Dept_Id,myList)
On this line it is giving me:
Error: Argument 2 must be named, not unnamed