[R] Odp: Apply function

Petr PIKAL petr.pikal at precheza.cz
Tue Nov 11 11:10:28 CET 2008


Hi

r-help-bounces at r-project.org napsal dne 11.11.2008 06:59:55:

> 
> Hi all
> 
> I am manipulating a datafram which has 3 variables.Such as:
> 
> 1  2  3
> 4  5  6
> . 
> .
> .
> 200  210  300
> 
> I also has a row index: index=c(100,200,250..300)
> I want to find the sums of first 100 rows, then the sum from row 101 to 
row
> 200, then row 201 to row 250... the each end row is indicated by the 
index.

A little bit vague question, hence vague answer.

make a factor which has 3 values repeated 100 times (rep) and then use 
almost any of aggregation function ( e.g. tapply, by, aggregate) with sum 
function.

Regards
Petr

> 
> Can I use the apply function to do that? or any other way?
> 
> Thanks
> 
> Ted
> 
> 
> -- 
> View this message in context: http://www.nabble.com/Apply-function-
> tp20434042p20434042.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list