[R] disaggregating table

2006-10-23 Thread Jeff Miller
Hi all,

 

This should be easy, but I can't seem to figure it out.

 

I have a table like this named newtable

 

a1  a2  a3  a4  Cnts  Score

1 100 4  3.28

1 011 2  2.63

 

I want the following:

 

a1  a2  a3  a4  Cnts  Score

1 100 4  3.28

1 100 4  3.28

1 100 4  3.28

1 100 4  3.28

1 011 2  2.63

1 011 2  2.63

 

Actually, the Cnts column could be removed, but it doesn't matter if it
stays.

 

Anyone know how to disaggregate with Cnts as the index?

 

Thanks,

Jeff

 


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] disaggregating table

2006-10-23 Thread Prof Brian Ripley
On Sun, 22 Oct 2006, Jeff Miller wrote:

 Hi all,

 This should be easy, but I can't seem to figure it out.

ind - rep(1:nrow(newtable), times=newtable$Cnts)
newtable[ind, -5]

gives

 a1 a2 a3 a4 Score
11  1  0  0  3.28
1.1  1  1  0  0  3.28
1.2  1  1  0  0  3.28
1.3  1  1  0  0  3.28
21  0  1  1  2.63
2.1  1  0  1  1  2.63

Note the row names: data frames must have unique row names.

 I have a table like this named newtable

 a1   a2   a3   a4  Cnts Score
 1 100 4  3.28
 1 011 2  2.63

 I want the following:

 a1   a2   a3   a4  Cnts Score
 1 100 4  3.28
 1 100 4  3.28
 1 100 4  3.28
 1 100 4  3.28
 1 011 2  2.63
 1 011 2  2.63

 Actually, the Cnts column could be removed, but it doesn't matter if it
 stays.

 Anyone know how to disaggregate with Cnts as the index?

   [[alternative HTML version deleted]]

Please use properly formatted plain text, as we do ask in the posting 
guide.  I've had to reformat the double-spaced text provided before 
pasting the table.

 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.