In the nested list below, I need to set row names to resource
and the row names should be taken from bodyPart
. I want this to be applied to all objects (e.g., obj1, obj2)
obj1 <- list(resource = list(bodyPart = c("leg", "arm", "knee"),side = c("LEFT", "RIGHT", "LEFT"), device = c("LLI", "LSM", "GHT")), cat = list(lab = c("aa", "bb", "cc")))
obj2 <- list(resource = list(bodyPart = c("leg", "arm", "knee"), side = c("LEFT", "LEFT", "LEFT"), device = c("GOM", "LSM", "YYY")))
x <- list(foo = c(fer = "wdb", obj1), bar = obj2)
I would like the output to look like this at resource level, for instance for obj2.
bodyPart | side | device | |
---|---|---|---|
leg | leg | LEFT | GOM |
arm | arm | LEFT | LSM |
knee | knee | LEFT | YYY |
I appreciate your edvice.