[R] two questions

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Mon Apr 15 15:29:48 CEST 2002


On Mon, 15 Apr 2002, Ambrosini Alessandro wrote:

> 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

x <- c(1,1,3,2,1,1)
wm <- which.min(x)	# first position

> would like to obtain a new vector as (1,2,5,6) that give me all the
> positions of the minimum value 1.

which(x == wm) 

> 
> 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 <- matrix(1:25, ncol=5)
A[-2,-4] 		# delete 2nd row and 4th col
     [,1] [,2] [,3] [,4]
[1,]    1    6   11   21
[2,]    3    8   13   23
[3,]    4    9   14   24
[4,]    5   10   15   25

Torsten

> Thank you.
>            Alessandro
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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