On Jul 8, 2011, at 12:24 AM, nanthinee wrote:

Hi,

I have a dataset:

 freq   x
1  30    7
3  70    8
4  100  7
5  22    6
6  250  10

perhaps (untested):

c( apply(ds,1,function(x) rep(x[2], x[1]) ) )

also perhaps (since I think rep is vectorised):

rep(ds$x, ds$freq)


How do I convert into vector form (v<- 7,7,7,8,8,8,6,6,6,6) all "x" with the complete frequency? Transpose only does a single row but I want the full
frequencies not just the variable transposed.

Thanks,
Nanthinee


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-convert-matrix-with-frequency-variable-to-vector-tp3653196p3653196.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to