[R] disaggregate frequency table into flat file
maiya
maja.zaloznik at gmail.com
Thu May 22 16:50:29 CEST 2008
Marc, it's the second "expansion" type transformation I was after, although
your expand.dft looks quite complicated? here's what I finaly came up with -
the bold lines correspond to what expand.dft does?
> orig<-matrix(c(40,5,30,25), c(2,2))
> orig
[,1] [,2]
[1,] 40 30
[2,] 5 25
> flat<-as.data.frame.table(orig)
> ind<-rep(1:nrow(flat), times=flat$Freq)
> flat<-flat[ind,-3]
> sample<-matrix(table(flat[sample(1:length(ind),10),]), c(2,2))
> sample
[,1] [,2]
[1,] 4 2
[2,] 1 3
So i get from the orig matrix to the sample matrix, expanding and
contracting it back in between!
It's just that I was hoping there was a more direct way of doing it!
Thanks!
maja
--
View this message in context: http://www.nabble.com/disaggregate-frequency-table-into-flat-file-tp17396040p17405966.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list