Hi:

Using an inelegant loop...

df <- matrix(rnorm(20000), 100, 200)
res <- numeric(100)
for (i in 1:100)
  res[i] <- sum(pmin(df[, i], df[, 100 +i]))/sum(df[, 100 + i])
res

HTH,
Dennis

On Fri, Jan 29, 2010 at 8:25 AM, Thiem Alrik <th...@sipo.gess.ethz.ch>wrote:

> Dear Mailing List Members,
>
> the problem I've been grappling with für quite some time now is the
> following:
>
> I have a 100 rows x 200 columns matrix.
>
> data.set <- matrix(rnorm(20000, 100, 200))
>
> Now I would like to get a vector of length 100 which collects the values
> from the following procedure:
>
> Take the sum of the minima of the two values from each row of columns 1 and
> 101, and divide it by the sum of column 101.
> Do the same for column 2 and 102, 3 and 103 and so on.
>
> Thanks a lot for your help.
>
> Alrik
>
> *******************************************
> Alrik Thiem
> Research Assistant
>
> WEC E17
> Weinbergstrasse 11
> Center for Comparative and International Studies (CIS)
> and Center for Security Studies (CSS)
> Swiss Federal Institute of Technology Zurich
> CH-8092 Zurich
>
> Tel.: 0041 44 63 20937
> th...@sipo.gess.ethz.ch
> http://www.cis.ethz.ch/
> http://www.css.ethz.ch/
> *******************************************
>
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to