r - do.call vs rbind, keeping rownames -
when using rbind
vs do.call(rbind, x)
. why , how do.call
operation maintain parent list names , not rbind
?
also, if replicate behaviour of do.call within rbind, retrieving parent list name , pass along row-name, how done smooth possible?
consider named list:
(l <- list(a=data.frame(x=1, y=2), b=data.frame(x=2, y=3))) # $a # x y # 1 1 2 # # $b # x y # 1 2 3
as note, do.call
rbind
passes names of list elements, results in row names combined data frame:
do.call(rbind, l) # x y # 1 2 # b 2 3
to these names using rbind
alone, need provide named arguments function:
rbind(a=l[["a"]], b=l[["b"]]) # x y # 1 2 # b 2 3
Comments
Post a Comment