Re: [R] min() return factor class values

From: Zoltan Kmetty <zkmetty_at_gmail.com>
Date: Tue 09 Jan 2007 - 14:57:27 GMT

Hi Milton!

I don't know why, but this thing happend with me too, quite a lot times. It's a useful way that convert the value type like that:

*as.numeric(as.character(min(...)))*

Zoltan

2007/1/9, Milton Cezar Ribeiro <milton_ruser@yahoo.com.br>:
>
> Hi R-friends
>
> I donīt know why the "min()" function below return the min value as
> factor. When i force the aicc.min using a as.numeric() function, it return
> a factor index (1,2,..) and not min value as I want. By the way, I included
> a sessionInfo() at the end of this e-mail.
>
> In fact I had the same problem (values as factor) on other part of my
> script and I noticed that it occour when I use "cbind()". It is real?
>
> Any idea?
>
> Kind regards,
>
> Miltinho
>
> > especies.aicc.min<-data.frame()
> > for (sp in levels(especies.aicc$especie))
> + {
> + sele<-subset(especies.aicc,especie==sp)
> + especies.aicc.min<-rbind(especies.aicc.min,cbind(sp,aicc.min=min
> (sele$aicc)))
> + }
> > especies.aicc.min
> sp aicc.min
> 1 Attila.rufus 6.7387056413613
> 2 Automolus.leucophthalmus 125.791300522824
> > class(especies.aicc.min$aicc.min)

> [1] "factor"
> >
> -----------
> > sessionInfo()
> R version 2.4.0 (2006-10-03)
> i386-pc-mingw32
> locale:
>
> LC_COLLATE=English_Jamaica.1252;LC_CTYPE=English_Jamaica.1252;LC_MONETARY=English_Jamaica.1252;LC_NUMERIC=C;LC_TIME=English_Jamaica.1252
> attached base packages:
> [1] "methods" "stats" "graphics" "grDevices" "utils"
> "datasets" "base"
> >
>
>
> __________________________________________________
>
>
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
>
>

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch 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. Received on Wed Jan 10 14:37:05 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 Jan 2007 - 04:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.