[R] two questions

Christoph Lange clange at epost.de
Mon Apr 15 18:42:47 CEST 2002


(Reply to Ambrosini Alessandro)


> The first: if I have a vector as (1,1,3,2,1,1), which is the command that
> gives all the positions of the min value? From the vector of the example a
> would like to obtain a new vector as (1,2,5,6) that give me all the
> positions of the minimum value 1.

> x <- c(1,1,3,2,1,1)
> x[x==min(x)]
[1] 1 1 1 1
> which(x==min(x))
[1] 1 2 5 6
> 

> The second: if I have a matrix "A" and I want to obtain a new matrix
> deleting a column or a row of A, what have I to do?

> A
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> A[,-2]
     [,1] [,2]
[1,]    1    7
[2,]    2    8
[3,]    3    9
> A[-2,]
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    3    6    9
> 

That's the solutions.

  Christoph.

-- 
Christoph Lange                                    clange at epost.de
Verhaltensbiologie, FU Berlin                            838-55068
Haderslebener Str. 9, 12163 Berlin
http://www.verhaltensbiologie.fu-berlin.de/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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