user1486507
user1486507

Reputation: 709

R - merge lists into one without putting each list's number

I have bunch of lists like this:

out[3]

[[3]]

[1] "forum=28&mid=11883" 
[2] "forum=29&mid=11884" 

out[4]

[[4]]

[1] "forum=30&mid=11885" 
[2] "forum=31&mid=11886" 

the outcome that I want is

[1] "forum=28&mid=11883"

[2] "forum=29&mid=11884" 

[3] "forum=30&mid=11885" 

[4] "forum=31&mid=11886" 

without [3], [4] (the order of each list) into the output list. Most of the "combine list" method out there (i.e. c(list1,list2), combine, paste, rbind..) made me include the order of each list like below

Any suggestions? will be much appreciated. ( I was thinking about convert lists to dataframe and use rbind, but I have 50,000 lists (longer than this) and i expect it will slow down the process so I didn't go to that path..)

Upvotes: 0

Views: 4723

Answers (1)

Andrie
Andrie

Reputation: 179468

Just use unlist(). Here is an example:

out <- list(
  c("a", "b"),
  c("c", "d")
)

out[[1]]
[1] "a" "b"

Now use unlist()

unlist(out)
[1] "a" "b" "c" "d"

Upvotes: 2

Related Questions