Re: [R] Conditional operations in R

2012-09-18 Thread ramoss
Thanks to all who responded, particularly to Michael. Your solution was the easiest to understand & to implement. This worked beautifully: cmtot <- arrange(cmtot, -PCTTOT)#sort by descending top <- with(cmtot,which.max(cumsum(PCTTOT) >= 50)) topcm <- cmtot[seq(1,top),] -- View this message

Re: [R] Conditional operations in R

2012-09-18 Thread Rui Barradas
Hello, In R you would use vectorized instructions, not a do while loop. dat <- read.table(text=" client pct_total A 15% B 10% C 10% D 9% E 8% F 6% G 4% ", header = TRUE) # Make it numeric dat$pct_total <- with(dat, as.numeric(su

Re: [R] Conditional operations in R

2012-09-18 Thread Bert Gunter
Have your read an Introduction to R? If not, do so before posting further. There are also many "R for SAS users" tutorials on the web I'm sure. Google or check CRAN. In particular, you need to understand how indexing works. See ?"[" and ?subset You will certainly have to define what you mean by "j

Re: [R] Conditional operations in R

2012-09-18 Thread R. Michael Weylandt
On Tue, Sep 18, 2012 at 3:41 PM, ramoss wrote: > Hello, > > I am a newbie to R coming from SAS background. I am trying to program the > following: > I have a monthly data frame with 2 variables: > > client pct_total > A 15% > B 10% > C 10% > D 9% > E

[R] Conditional operations in R

2012-09-18 Thread ramoss
Hello, I am a newbie to R coming from SAS background. I am trying to program the following: I have a monthly data frame with 2 variables: client pct_total A 15% B 10% C 10% D 9% E 8% F 6% G 4% I need to come up w/ a monthly list o