Re: [R] Determining a basal correct count

2010-11-24 Thread David Herzberg
ssage- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Thursday, October 28, 2010 4:59 PM To: David Herzberg Cc: r-help@r-project.org Subject: Re: [R] Determining a basal correct count David - I think changing apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1]) to appl

Re: [R] Determining a basal correct count

2010-11-01 Thread David Herzberg
4:59 PM To: David Herzberg Cc: r-help@r-project.org Subject: Re: [R] Determining a basal correct count David - I think changing apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1]) to apply(x,1,function(x)if(!any(x==1)) 0 else rle(x[which(x==1)[1]:length(x)])$lengths[1

Re: [R] Determining a basal correct count

2010-10-28 Thread Phil Spector
Thu, Oct 28, 2010 23:39:34 GMT+00:00 Subject: Re: [R] Determining a basal correct count David -     I *think*    apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1]) gives you what you want, but without a reproducible example it's hard to say.  It will fail if there

Re: [R] Determining a basal correct count

2010-10-28 Thread David Herzberg
0:00 Subject: Re: [R] Determining a basal correct count David - I *think* apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1]) gives you what you want, but without a reproducible example it's hard to say. It will fail if there are no 1s in a given row.

Re: [R] Determining a basal correct count

2010-10-28 Thread Phil Spector
David - I *think* apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1]) gives you what you want, but without a reproducible example it's hard to say. It will fail if there are no 1s in a given row. - Phil Spector

[R] Determining a basal correct count

2010-10-28 Thread David Herzberg
Here's another interesting problem: if you recall I have a data frame (LCvars1) that consists of about 1500 cases (rows) of data from kids who took a test of listening comprehension. The columns are their scores (1 = correct, 0 = incorrect, . = missing) on 140 test items. The items are numbered