Hi,
Just two variant's of David's solution:
idx<-apply(mydata[-1],2,function(x) any(!x %in% c(0,5)))
idx
x1x2x3x4
TRUE FALSE FALSE FALSE
idx<-c(TRUE,idx)
mydata[,idx]
#second
idx<-apply(mydata[-1],2,function(x) all(ifelse(x!=0 & x!=5,TRUE,FALSE )))
mydata[,c(TRUE,idx)]
n x1
; project.org] On Behalf Of john.james
> Sent: Wednesday, August 01, 2012 10:19 AM
> To: r-help@r-project.org
> Subject: [R] sub setting a data frame with binomial responses
>
> Hi everyone,
> Let me have a dataframe named “mydata” and created as below,
> *> n=c(5,5,5,5) #number of tri
Hi everyone,
Let me have a dataframe named “mydata” and created as below,
*> n=c(5,5,5,5) #number of trils
> x1=c(2,3,1,3) ) #number of successes
> x2=c(5,5,5,5) #number of successes
> x3=c(0,0,0,0) #number of successes
> x4=c(5,0,5,0) #number of successes
> mydata=data.frame(n,x1,x2,x3,x4)
> myda
3 matches
Mail list logo