0

I have 3 different lists in R as follows:

dput(emp_id)
dput(employee)
dput(roles)

list("E1201", "E2231", "E3451")
list("John", "James", "Jonie")
c("district manager", "cashier", "food preparer", "cashier")

I am trying to make it into a dataframe as follows:

EMP id   Employee    Roles 
E1201    John        ["district manager"]
E2231    James       ["cashier", "food manager"]
E3451    Jonie       []

I tried

df = cbind(dd, de, di) 

But it says that the arguments imply different rows. May i know whether there is any methods that can be used?

Coderz
  • 11
  • 3

1 Answers1

0

You can extend your vectors as follows:

rows <- max(length(di), length(de), length(dd))

dd <- c(dd, rep(NA, rows - length(dd)
de <- c(de, rep(NA, rows - length(de)
di <- c(di, rep(NA, rows - length(di)

If you know which one is the biggest one(s), you can tweak it accordingly

Daniel V
  • 1,305
  • 7
  • 23