Rahul Singh Syunari - 5 months ago 34

R Question

I have 121 data objects with names a1 a2 a3 ...so on till a121

How can I rbind it using a loop or something because writing the whole code

rbind(a1,a2,a3...) would be very tedious

Please help

Answer

```
Reduce("rbind", mget(paste0("a", 1:121)))
```

Small example :

```
a1 <- c(1, 2, 3)
a2 <- c(2, 4, 1)
a3 <- c(1, 2, 3)
rbind(a1, a2, a3)
# [,1] [,2] [,3]
#a1 1 2 3
#a2 2 4 1
#a3 1 2 3
Reduce("rbind", mget(paste0("a", 1:3)))
# [,1] [,2] [,3]
# 1 2 3
# 2 4 1
# 1 2 3
```