R Programming: Assign NULL to a given list element
R Programming: List Exercise-14 with Solution
Write a R program to assign NULL to a given list element.
Sample Solution :
R Programming Code :
l = list(1, 2, 3, 4, 5)
print("Original list:")
print(l)
print("Set 2nd and 3rd elements to NULL")
l[2] = list(NULL)
l[3] = list(NULL)
print(l)
Sample Output:
[1] "Original list:" [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 [[4]] [1] 4 [[5]] [1] 5 [1] "Set 2nd and 3rd elements to NULL" [[1]] [1] 1 [[2]] NULL [[3]] NULL [[4]] [1] 4 [[5]] [1] 5
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a R program to convert a given matrix to a list.
Next: Write a R program to create a list named s containing sequence of 15 capital letters, starting from ‘E’.
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