[R] i think i asked the wrong ?
John Fox
jfox at mcmaster.ca
Mon Feb 18 19:11:24 CET 2002
Dear Jimi,
At 08:26 AM 2/18/2002 -0500, you wrote:
>me again, new to R, haven't programmed in a long time at all
>sorry to ask what is probably basic
>
>a while ago i asked how to remove an element from a list
>apparently what i am using is not a list but a vector, didn't realize
>there was a list data type
>could also use a matrix for what i am doing, is there a way to remove
>single elements from either of those?
>
>thanks for any help, if i was actually using a list as i said last time,
>the answers i received would have cleared things right up
You can use negative indices to remove entries from a vector; for example,
> v <- 1:10
> v[-5]
[1] 1 2 3 4 6 7 8 9 10
> v[-c(3,6)]
[1] 1 2 4 5 7 8 9 10
Removing single elements from a matrix doesn't make sense -- what goes in
the hole? You can, however, remove entire rows or columns with negative
indices.
(Indexing is discussed in all of the basic introductions to R and S of
which I'm aware. It probably makes sense to read one of these -- you'll
save time in the long run.)
I hope that this helps,
John
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list