[R] Obtaining summary of frequencies of value occurrences for a variable in a multivariate dataset.
Adaikalavan Ramasamy
ramasamy at cancer.org.uk
Tue Jul 24 22:21:51 CEST 2007
The name of the table should give you the "value". And if you have a
matrix, you just need to convert it into a vector first.
> m <- matrix( LETTERS[ c(1:3, 3:5, 2:4) ], nc=3 )
> m
[,1] [,2] [,3]
[1,] "A" "C" "B"
[2,] "B" "D" "C"
[3,] "C" "E" "D"
> tb <- table( as.vector(m) )
> tb
A B C D E
1 2 3 2 1
> paste( names(tb), ":", tb, sep="" )
[1] "A:1" "B:2" "C:3" "D:2" "E:1"
If this is not what you want, then please give a simple example.
Regards, Adai
Allan Kamau wrote:
> Hi all,
> If the question below as been answered before I
> apologize for the posting.
> I would like to get the frequencies of occurrence of
> all values in a given variable in a multivariate
> dataset. In short for each variable (or field) a
> summary of values contained with in a value:frequency
> pair, there can be many such pairs for a given
> variable. I would like to do the same for several such
> variables.
> I have used table() but am unable to extract the
> individual value and frequency values.
> Please advise.
>
> Allan.
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>
>
More information about the R-help
mailing list