Please do read ?apply (see the posting guide)

     If 'X' is not an array but has a dimension attribute, 'apply'
     attempts to coerce it to an array via 'as.matrix' if it is
     two-dimensional (e.g., data frames) or via 'as.array'.

and note
sapply(esoph, class)
$agegp
[1] "ordered" "factor"

$alcgp
[1] "ordered" "factor"

$tobgp
[1] "ordered" "factor"

$ncases
[1] "numeric"

$ncontrols
[1] "numeric"


On Fri, 1 Aug 2008, David Hajage wrote:

Hello R users,

I run this code under windows XP and R 2.7.1 :

head(esoph)
 agegp     alcgp    tobgp ncases ncontrols
1 25-34 0-39g/day 0-9g/day      0        40
2 25-34 0-39g/day    10-19      0        10
3 25-34 0-39g/day    20-29      0         6
4 25-34 0-39g/day      30+      0         5
5 25-34     40-79 0-9g/day      0        27
6 25-34     40-79    10-19      0         7
class(esoph$agegp)
[1] "ordered" "factor"
class(esoph$alcgp)
[1] "ordered" "factor"
class(esoph$tobgp)
[1] "ordered" "factor"
class(esoph$ncases)
[1] "numeric"
class(esoph$ncontrols)
[1] "numeric"
apply(esoph, 2, class)
     agegp       alcgp       tobgp      ncases   ncontrols
"character" "character" "character" "character" "character"

I don't understand why the result is all "character"...

Thanks a lot.

        [[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.


--
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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