Re: [R] aggregate counting variable factors

2015-09-17 Thread Kai Mx
#x27; ? >> >> Regards >> >> >> On Thu, Sep 17, 2015 at 08:22:10AM +, PIKAL Petr wrote: >> >>> Hi >>> >>> -Original Message- >>>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kai Mx >>>>

Re: [R] aggregate counting variable factors

2015-09-17 Thread Rui Barradas
oun...@r-project.org] On Behalf Of Kai Mx Sent: Wednesday, September 16, 2015 10:43 PM To: r-help mailing list Subject: [R] aggregate counting variable factors Hi everybody, >From a questionnaire, I have a dataset like this one with some 40 items: df1 <- data.frame(subject=c('user1

Re: [R] aggregate counting variable factors

2015-09-17 Thread Frank Schwidom
ber 16, 2015 10:43 PM > > To: r-help mailing list > > Subject: [R] aggregate counting variable factors > > > > Hi everybody, > > > > >From a questionnaire, I have a dataset like this one with some 40 > > items: > > > > df1 <- data.fra

Re: [R] aggregate counting variable factors

2015-09-17 Thread Frank Schwidom
Hi res <- sapply( df1[ , -1], function( x) table(x)[as.character( 0:5)]) rownames( res) <- paste( sep='', 'result', 0:5) res[ is.na( res)] <- 0 res item1 item2 item3 item4 item5 result0 1 0 1 1 0 result1 1 2 0 0 0 result2 1 2 1 1

Re: [R] aggregate counting variable factors

2015-09-17 Thread PIKAL Petr
Hi > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kai Mx > Sent: Wednesday, September 16, 2015 10:43 PM > To: r-help mailing list > Subject: [R] aggregate counting variable factors > > Hi everybody, > > >From a questio

[R] aggregate counting variable factors

2015-09-16 Thread Kai Mx
Hi everybody, >From a questionnaire, I have a dataset like this one with some 40 items: df1 <- data.frame(subject=c('user1','user2', 'user3', 'user4'), item1=c(0,1,2,5), item2=c(1,2,1,2), item3=c(2,3,4,0), item4=c(0,3,3,2), item5=c(5,5,5,5)) Users can choose an answer from 0 to 5 for each item.