This is my list
list_names <- vector(mode = 'list')
list_names[['NAME A']] <- rnorm(n = 10,sd = 2)
list_names[['NAME B']] <- rnorm(n = 10,sd = 2)
list_names[['NAME C']] <- rnorm(n = 10,sd = 2)
list_names[['NAME D']] <- rnorm(n = 10,sd = 2)
list_names[['NAME E']] <- rnorm(n = 10,sd = 2)
list_names[['NAME F']] <- rnorm(n = 10,sd = 2)
Is it possible to select others elements of list doing something like this:
list_names[[-"NAME A"]]
The output should be a list with all elements except the "NAME A"
element?
Probably this is what you are after
list_names[-match('NAME A',names(list_names))]
!! WARNING: if the requested name is not a valid name of list_names
, then the solution will return NULL
(thanks for @akrun's comment)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With