R Programming: Merge two given lists into one list
R Programming: List Exercise-8 with Solution
Write a R program to merge two given lists into one list.
Sample Solution :
R Programming Code :
n1 = list(1,2,3)
c1 = list("Red", "Green", "Black")
print("Original lists:")
print(n1)
print(c1)
print("Merge the said lists:")
mlist = c(n1, c1)
print("New merged list:")
print(mlist)
Sample Output:
[1] "Original lists:" [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 [[1]] [1] "Red" [[2]] [1] "Green" [[3]] [1] "Black" [1] "Merge the said lists:" [1] "New merged list:" [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 [[4]] [1] "Red" [[5]] [1] "Green" [[6]] [1] "Black"
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a R program to create a list containing a vector, a matrix and a list and update the last element.
Next: Write a R program to convert a given list to vector.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics