[R] how to delete a matrix column
Ted Harding
Ted.Harding at wlandres.net
Sun Jun 17 21:58:04 CEST 2012
On 17-Jun-2012 17:24:21 ÀîºìÍú wrote:
>> a<-c(1,4)
>> a
> [1] 1 4
>> b<-a*5
>> b
> [1] 5 20
>
> a is a very long vector , how can i get c(1:5,4:20)?
> i do not want to use a loop.
>
> thanks very much!
Your question is not quite clear, but I think you mean:
a is a very long vector, and you want a vector with elements
a[1],a[2],a[3],a[4],a[5],a[4],a[5],a[6],...,a[20]
If that is the case, then a[c(1:5,4:20)] will do it. Example:
a <- (1:100)
a[c(1:5,4:20)]
# [1] 1 2 3 4 5 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Does that help?
If not, try to re-formulate the question!
Ted.
-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 17-Jun-2012 Time: 20:58:01
This message was sent by XFMail
More information about the R-help
mailing list