11
I have this list:
x = list(1, 3, 5, 8, 13)
How do I delete the second element?
11
I have this list:
x = list(1, 3, 5, 8, 13)
How do I delete the second element?
9
Another way that serves for any R object, and not just lists, is not to select the element you want to remove and assign back to the original object:
x <- x[-2]
7
In accordance with the documentation of R
, simply set null to the element you want to remove:
x[[2]] <- NULL
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.