On Sun, Jan 11, 2009 at 9:04 PM, Jörg Groß <jo...@licht-malerei.de> 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[...] selects a *subsequence*,
not an *element*.  Only x[[...]] selects an element. What makes this
confusing to learn is that for vectors, a subsequence of length 1 is treated
the same as an element.  But for lists, they are not the same thing.

You can iterate over the columns in various ways, e.g.

    for (i in 1:length(d)) ... d[[i]] ...
    for (i in names(d)) ... d[[i]] ...


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

Remember that

       d$x == d[["x"]]

Hope this helps,

          -s

        [[alternative HTML version deleted]]

______________________________________________
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