Q:

Write a R program to assign NULL to a given list element

0

Write a R program to assign NULL to a given list element.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now