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       f  6
7       f  7
8       f  8
9       f  9
10      f 10


now I want to get the mean and sd, as long as the column is not of type factor.
So the function should skip the first column.


But how can I check this, if I don't know the column name?

Because

is.factor(d[1])
produces "FALSE".

Only
is.factor(d$x)
gives the correct result.


But how can I check the column if I don't know the column name?


I tried s.th. like this;

is.factor(d$names(d[1]))


but that kind of structure is not possible.



Can someone help me with that problem?

______________________________________________
R-help@r-project.org 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.

Reply via email to