-3

I have 40 data frames (same size) let's say station_1, station_2,....,station_40

In each loop there will be different stations that need to be vertically concatenated. For example, in a particular loop, i want to concatenate [station_2, station_3, station_11, station_30, station_40]. How can i code the R to do that without explicitly specifying the names of those station?

1 Answers1

0

We can get the datasets in a list using mget and then rbind them (assuming vertically concatenated implies that) with do.call

res <- do.call(rbind, mget(paste0("station_", c(2, 3, 11, 30, 40))))

NOTE: Here we assume that the dataset objects have the same column names

akrun
  • 874,273
  • 37
  • 540
  • 662