1

I have 6 numeric lists each containing different number of values i.e [1:350] , [1:450] .... . I am trying to append all of these lists into a singular list i.e [1:1050] using rbind(), but the output I get is dataframe of [1:350, 1:6].

Can someone please help me with this.

3442
  • 8,248
  • 2
  • 19
  • 41
show_stopper
  • 288
  • 5
  • 17
  • 4
    You can use the `c` function to concatenate all the lists. `c(list1, list2, ...)` – Rich Scriven Oct 09 '14 at 22:45
  • @nar, in order to get a precise answer you should be more specific. Is it a list, or a vector that you have. What does `class(your_list)` return? '6 numeric lists' does not describe the entire picture, in R list elements can mix types. – TarasB Oct 09 '14 at 23:21

1 Answers1

3

To concatenate multiple lists, you can use c()

x <- list(1, 2:5)
y <- list("A", "B")
z <- list(letters[1:5])
c(x, y, z)
# [[1]]
# [1] 1
#
# [[2]]
# [1] 2 3 4 5
#
# [[3]]
# [1] "A"
#
# [[4]]
# [1] "B"
#
# [[5]]
# [1] "a" "b" "c" "d" "e"
Rich Scriven
  • 97,041
  • 11
  • 181
  • 245