On Sun, Jan 11, 2009 at 9:04 PM, Jörg Groß wrote:
> ...now I want to get the mean and sd, as long as the column is not of type
> factor.
> ...But how can I check this, if I don't know the column name?
>
...
> is.factor(d[1])
> produces "FALSE".
>
Try is.factor(d[[1]]). Remember that in R, x[...
try this:
> d <- data.frame(c(rep("m",5), rep("f",5)), c(1:10))
> names(d) <- c("x", "y")
> d
x y
1 m 1
2 m 2
3 m 3
4 m 4
5 m 5
6 f 6
7 f 7
8 f 8
9 f 9
10 f 10
> lapply(d, function(x) if (is.numeric(x)) c(mean=mean(x), sd=sd(x)))
$x
NULL
$y
mean sd
5.50 3.027
Hi,
I try to write an own function in R.
I want a summary table with descriptive statistics.
For example, I have this data.frame:
d <- data.frame(c(rep("m",5), rep("f",5)), c(1:10))
names(d) <- c("x", "y")
d
x y
1 m 1
2 m 2
3 m 3
4 m 4
5 m 5
6
3 matches
Mail list logo