Re: [R] how to eliminate an element of a list

2010-08-13 Thread Michael Bedward
Hello André, I want to eliminate an element of a list: list - seq(1,5,1) That's not a list, it's a vector s - sample(list,1) lets say s=3 Now I want to remove 3 from the list: list2 = {1,2,4,5} If all values are unique as in your example, this will work x - 1:5 s - sample(x, 1) x - x[ x

Re: [R] how to eliminate an element of a list

2010-08-13 Thread fishkbob
list-seq(2,10,2) list [1] 2 4 6 8 10 list[-which(2==list)] [1] 4 6 8 10 using the which() will let you remove things from a list that have a specified value... I usually use the blah- blah[-which(TRUE==is.na(blah)) ] which will remove all NA values in your list -- View this message

Re: [R] how to eliminate an element of a list

2010-08-13 Thread fishkbob
Try to do this list - seq(1,5,1) list-list[-3] list [1] 1 2 4 5 list[-x] will remove the xth value in your list. Also you can do something like list[-c(1:4)] [1] 5 To remove values at indexes 1-4 list[-c(1,4)] [1] 2 3 5 To remove values at indexes 1 and 4 -- View this message in

Re: [R] how to eliminate an element of a list

2010-08-13 Thread David Winsemius
On Aug 13, 2010, at 4:06 PM, fishkbob wrote: list-seq(2,10,2) list [1] 2 4 6 8 10 list[-which(2==list)] [1] 4 6 8 10 using the which() will let you remove things from a list that have a specified value... I usually use the blah- blah[-which(TRUE==is.na(blah)) ] which will remove

[R] how to eliminate an element of a list

2010-08-12 Thread André de Boer
Hi, I want to eliminate an element of a list: list - seq(1,5,1) s - sample(list,1) lets say s=3 Now I want to remove 3 from the list: list2 = {1,2,4,5} Can someone give me a tip? Thanks, André [[alternative HTML version deleted]] __

Re: [R] how to eliminate an element of a list

2010-08-12 Thread Henrique Dallazuanna
Try this: setdiff(list, s) On Thu, Aug 12, 2010 at 5:32 PM, André de Boer rnie...@gmail.com wrote: Hi, I want to eliminate an element of a list: list - seq(1,5,1) s - sample(list,1) lets say s=3 Now I want to remove 3 from the list: list2 = {1,2,4,5} Can someone give me a tip?