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
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
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
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
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]]
__
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?
6 matches
Mail list logo