Skip to content
Prev 131467 / 398502 Next

Help rewriting looping structure?

This will give you the percents in the same order as your original data (as
this is what your original code did)

apply(tdat, 2,
function(x) {
	o <- order(x)
	oldo <- order(o)
	prc <- cumsum(x[o]) / sum(x)
	prc[oldo]
})

Jason Law
Statistician
City of Portland, Bureau of Environmental Services
Water Pollution Control Laboratory
6543 N Burlington Avenue
Portland, OR 97203 -5452
jlaw at bes.ci.portland.or.us



-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org]On Behalf Of TLowe
Sent: Thursday, December 06, 2007 10:28 AM
To: r-help at r-project.org
Subject: Re: [R] Help rewriting looping structure?



Thank you all.  That's exactly what I was looking for.
TLowe wrote: