I would like to find a way to create a data.frame by using cbind()
to join together many separate objects. For example, if A, B, C & D are all vectors of equal length, one can create data.frame
ABCD with
ABCD <- cbind(A,B,C,D)
However, when the number of objects to be combined gets large, it becomes tedious to type out all of their names. Furthermore, Is there a way to call cbind()
on a vector of object names, e.g.
objs <- c("A", "B", "C", "D")
ABCD <- cbind(objs)
or on a list containing all the objects to be combined, e.g.
obj.list <- list(A,B,C,D)
ABCD <- cbind(obj.list)
Currently, the only workaround I can think of is to use paste()
, cat()
, write.table()
, and source()
to construct the arguments to cbind()
, write it as a script and source it. This seems like a very nasty kludge. Also, I have looked into do.call()
but can't seem to find a way to accomplish what I want with it.
Reduce(cbind, obj.list)
could also be used in addition to the answer by @prasad-chalasani. – Acacia