I have this list:
x = list(1, 3, 5, 8, 13)
How do I delete the second element?
I have this list:
x = list(1, 3, 5, 8, 13)
How do I delete the second element?
Another way for any R object, not just lists, is not to select the element you want to remove and assign it back to the original object:
x <- x[-2]
According to documentation of R
, just assign null to the element you want to remove:
x[[2]] <- NULL