How can I rbind a list of data frames using only specific columns? Something like do.call(rbind, data)
works fine, but I dont't know how to exclude a vector of specific columns. Dropping unnecessary columns afterwards seems is ok, but maybe there is a cleaner way to do this?
Asked
Active
Viewed 1,791 times
1

Matthias Preu
- 783
- 2
- 8
- 18
-
5See: [How to drop columns by name in a data frame](http://stackoverflow.com/questions/5234117/how-to-drop-columns-by-name-in-a-data-frame) – Jaap Feb 03 '16 at 12:19
-
1Do you want to `merge` or `rbind`? You need to get your definitions straight. – David Arenburg Feb 03 '16 at 12:35
-
Edit original post. I want to use `rbind`. – Matthias Preu Feb 03 '16 at 13:24
1 Answers
1
I can simply use subset
(thanks to @Jaap):
do.call(rbind, lapply(data, subset, select=c("use_this", "and_this")))

Matthias Preu
- 783
- 2
- 8
- 18