[R] (kein Betreff)

Pedro Rodrigues prodrigues at dcc.fc.up.pt
Wed Mar 31 19:08:46 CEST 2004


On Wed, 2004-03-31 at 19:01, Mag. Ferri Leberl wrote:
> Dear colleagues!
> 
> How can I calculate the mean of every line of "feld" without using the command 
> "for"?
> 
> Thank You in advance
> 
> 
> feld<-array(,c(100,10))
> mittel<-array(,c(100,1))
> feld[,]<-rnorm(1000)
> for(a in 1:100){mittel[a]<-mean(feld[a,])}

You could use:

mittel <- apply(feld, 1, mean)

prodrigues

> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list