Re: [R] disaggregate frequency table into flat file

From: maiya <maja.zaloznik_at_gmail.com>
Date: Thu, 22 May 2008 05:56:46 -0700 (PDT)

sorry, my mistake!
the data frame should read:
orig<-as.data.frame.table(orig)
orig
 Var1 Var2 Freq
1 A A 40
2 B A 5
3 A B 30
4 B B 25

but basicaly i would simply like a sample of the original matrix ( which is a frequency table/contingency table/crosstabulation)

hope this is clearer now!

maja

jholtman wrote:

> 
> Not exactly clear what you are asking for.  Your data.frame.table does not
> seem related to the original 'orig'.  What exactly are you expecting as
> output?
> 
> On Wed, May 21, 2008 at 10:16 PM, maiya <maja.zaloznik_at_gmail.com> wrote:
> 

>>
>> 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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem you are trying to solve?
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/disaggregate-frequency-table-into-flat-file-tp17396040p17403687.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 - 13:32:58 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 - 14: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