Re: [R] faster way?

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Mon 11 Sep 2006 - 06:47:21 GMT

Rick Bischoff wrote:
> Hi,
>
> Is there a faster way to do this? It takes forever, even on a
> moderately sized dataset.
>
>
> n <- dim(dsn)[1]
> dsn2 <- dsn[order(-dsn$xhat),]
> dsn2[1, "cumx"] <- dsn2[1, "xhat"]
>
> for (i in 2:n) {
> dsn2[i, "cumx"] <- dsn2[i - 1, "cumx"] + dsn2[i, "xhat"]
> }

dsn2 <- dsn[order(-dsn$xhat),]
dsn2[,"cumx"] <- cumsum(dsn2[,"xhat"])

>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.



R-help@stat.math.ethz.ch 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. Received on Mon Sep 11 16:52:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 11 Sep 2006 - 08:30:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.