Skip to content
Prev 319604 / 398506 Next

Data manipulation

Hello John, 


I thought I attached the file. So here we go: 
Class=c(1,1,1,1,	1,1,1,2,	2,2,2,2,	2,2,3,3,
3,3,3,3,	3,3,3)
X=c(0.1,0.1,0.1,	0.1,0.2,	0.2,0.2,	0.1,0.1,
0.1,0.1,0.1,0.1,0.1,0.1,0.2,0.2,0.2,0.2,0.3,0.3,0.3,	0.3)
Count=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

by1<-factor(Class)
by2<-factor(X)
W<-aggregate(x=Count,by=list(by1,by2),FUN="sum")

 

However, what I want is a table that also include lines for the Group.1 and
Group.2 values for which there are no records. In other words something like
this:

 

Thanks again. I hope its clearer now. 
Ioanna


-----Original Message-----
From: John Kane [mailto:jrkrideau at inbox.com] 
Sent: 15 March 2013 12:51
To: IOANNA; r-help at r-project.org
Subject: RE: [R] Data manipulation

What zero values?  And are they acutall zeros or are the NA's, that is,
missing values?

The code looks okay but without some sample data it is difficult to know
exactly what you are doing. 

The easiest way to supply data  is to use the dput() function.  Example with
your file named "testfile": 
dput(testfile)
Then copy the output and paste into your email.  For large data sets, you
can just supply a representative sample.  Usually, 
dput(head(testfile, 100)) will be sufficient.   

 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducibl
e-example

Please supply some sample data. 
 

John Kane
Kingston ON Canada
____________________________________________________________

family!
[[elided Hotmail spam]]