J.Andrés Martínez
2007-May-24 09:07 UTC
[R] Function to convert categorical variable in numerical
Se ha borrado un texto insertado con un juego de caracteres sin especificar... Nombre: no disponible Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070524/d8dfb2c3/attachment.pl
Prof Brian Ripley
2007-May-24 09:36 UTC
[R] Function to convert categorical variable in numerical
?model.matrix ?contr.treatment Whether this makes sense for PCA is another matter: princomp() contains a test to stop this happening automatically with a formula argument. One problem is the result depends on just how you do the transformation. On Thu, 24 May 2007, J.Andr?s Mart?nez wrote:> Hello everybody, > > I am a new R user. At current moment I need to do a Principal Components > Analysis with a table who contain mixed variables (categorical and > numerical). There is some function available in R for transform these > variables? > > For example: I need transform the categorical variable X who has 3 classes > in 2 numerical variables with 0s and 1s. > > Thank you very much, > J. Andres > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk 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
Mark Difford
2007-May-24 09:55 UTC
[R] Function to convert categorical variable in numerical
Hi J. Andres, You are probably better off using the ade4 package, which has two functions that will do exactly what you want, i.e. a PCA using mixed quantitative and categorical variables: ## You will need to download ade4 first library(ade4) ?dudi.hillsmith ?dudi.mix Regards, Mark Difford. J.Andr?s Mart?nez wrote:> > Hello everybody, > > I am a new R user. At current moment I need to do a Principal Components > Analysis with a table who contain mixed variables (categorical and > numerical). There is some function available in R for transform these > variables? > > For example: I need transform the categorical variable X who has 3 classes > in 2 numerical variables with 0s and 1s. > > Thank you very much, > J. Andres > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. > >-- View this message in context: http://www.nabble.com/Function-to-convert-categorical-variable-in-numerical-tf3808888.html#a10780667 Sent from the R help mailing list archive at Nabble.com.