Try this:
library(gsubfn)
demo("gsubfn-cut")
and note the strapply call that converts the levels from cut to a matrix.
On Sun, Nov 8, 2009 at 4:08 PM, jose romero wrote:
> Hello list:
>
> I am using "cut" and "table" to obtain a frequency table from a numeric
> sample vector. The idea is to c
jose romero wrote:
Hello list:
I am using "cut" and "table" to obtain a frequency table from a
numeric sample vector. The idea is to calculate mean and standard
deviation on grouped data. However, I can't extract the midpoints of the
class intervals, which seem to be strings treated as factors.
Hi,
Maybe something like this (inspired by ?cut),
cut2num <- function(f){
labs <- levels(f)
d <- data.frame(lower = as.numeric( sub("\\((.+),.*", "\\1", labs) ),
upper = as.numeric( sub("[^,]*,([^]]*)\\]", "\\1", labs) ))
d$midpoints <- rowMeans(d)
d
}
a <- c(1, 2, 3, 4
Hello list:
I am using "cut" and "table" to obtain a frequency table from a numeric sample
vector. The idea is to calculate mean and standard deviation on grouped data.
However, I can't extract the midpoints of the class intervals, which seem to be
strings treated as factors. How do i extrac
4 matches
Mail list logo