[R] How to convert matrix with frequency & variable to vector?
dwinsemius at comcast.net
Fri Jul 8 06:33:32 CEST 2011
On Jul 8, 2011, at 12:24 AM, nanthinee wrote:
> I have a dataset:
> freq x
> 1 30 7
> 3 70 8
> 4 100 7
> 5 22 6
> 6 250 10
c( apply(ds,1,function(x) rep(x, x) ) )
also perhaps (since I think rep is vectorised):
> 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
> frequencies not just the variable transposed.
> 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 at r-project.org mailing list
> 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
More information about the R-help