[R] disaggregate frequency table into flat file

From: maiya <maja.zaloznik_at_gmail.com>
Date: Wed, 21 May 2008 19:16:30 -0700 (PDT)

i appologise for the trivialness of this post - but i've been searching the forum wothout luck - probably simply because it's late and my brain is starting to go..

i have a frequency table as a matrix:

orig<-matrix(c(40,5,30,25), c(2,2))
orig

     [,1] [,2]
[1,] 40 30
[2,] 5 25

i basically need a random sample say 10 from 100:

     [,1] [,2]
[1,] 5 2
[2,] 0 3

i got as far as

orig<-as.data.frame.table(orig)
orig
 Var1 Var2 Freq
1 A A 10
2 B A 5
3 A B 30
4 B B 25

and then perhaps

individ<-rep(1:4, times=orig$Freq)

which gives a vector of the 100 individuals in each of the 4 groups - cells, but I'm
(a) stuck here and
(b) afraid this is a very round-about way at getting to what I want i.e. I can now sample(individ, 10), but then I'll have a heck of a time getting the result back into the original matrix form....

sorry again, just please tell me the simple solution that I've missed?

thanks!

maja

-- 
View this message in context: http://www.nabble.com/disaggregate-frequency-table-into-flat-file-tp17396040p17396040.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org 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.
Received on Thu 22 May 2008 - 08:43:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 22 May 2008 - 13:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive