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
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
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
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.
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
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
6 matches
Mail list logo