R-helpers:
I'm trying to determine the frequency of characters for a matrix
applied to a single dimension, and generate a matrix as an output.
I've come up with a solution, but it appears inelegant -- I was
wondering if there is an easier way to accomplish this task:
# Create a matrix of factors
On Jul 10, 2014, at 12:03 PM, Jonathan Greenberg j...@illinois.edu wrote:
R-helpers:
I'm trying to determine the frequency of characters for a matrix
applied to a single dimension, and generate a matrix as an output.
I've come up with a solution, but it appears inelegant -- I was
You can make make a factor with a common set of levels out of each slice of
the matrix so all the tables are the same size:
f - function (charMatrix, levels = unique(sort(as.vector(charMatrix
{
apply(charMatrix, 1, function(x) table(factor(x, levels = levels)))
}
used as
m -
3 matches
Mail list logo