3
I have the following list:
x <- list("1", 1, 2, 2.1, TRUE, "yes", "necessary", 31, FALSE, "FALSE")
would like to exclude from it all the elements which NAY are whole numbers and not characters, in which case the elements which are in heading [4], [5] and [9] I’ve tried to make:
x <- x[-4][-5][-9]
however only the first element is removed correctly, so that the index of each later element is changed with the one removed from the first, the list is:
[[1]]
[1] "1"
[[2]]
[1] 1
[[3]]
[1] 2
[[4]]
[1] TRUE
[[5]]
[1] "necessary"
[[6]]
[1] 31
[[7]]
[1] FALSE
[[8]]
[1] "FALSE"
how to remove the items from position [4], [5] and [9] without changing the index of unwanted items?
Try it like this
x2 = x[c(-4,-5,-9)]
– Thiago Fernandes