Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (5.3k points)

I have two lists:

l1 = list(2, 3)

l2 = list(4)

I want a third list:

list(2, 3, 4).

How can I do it in a simple way? Although I can do it in for loop, I am expecting a one-liner answer, or maybe an in-built method.

Actually, I have a list:

list(list(2, 3), list(2, 4), list(3, 5), list(3, 7), list(5, 6), list(5, 7), list(6, 7)).

After computing on list(2, 3) and list(2, 4), I want list(2, 3, 4).

1 Answer

0 votes
by

You can use the c() function to combine two lists as follows:

l1 = list(2, 3)

l2 = list(4)

> c(l1, l2)

[[1]]

[1] 2

[[2]]

[1] 3

[[3]]

[1] 4

Related questions

0 votes
1 answer
+2 votes
3 answers
0 votes
1 answer
asked Aug 1, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer

Browse Categories

...