Hoy, I have the following problem. I have to import the dataset (survey) from SPSS into R-programm. By using the "read.spss" the all of variables have been readed as factor. I need the variables "income" and "age" as numeric for the regreesion analysis. Could you plese help me. Thanks a lot, best regards, Silika
How to convert a factor to numeric is one of the questions (with answers) in R's FAQ. Assuming you don't need to do this again, I would just convert what you have imported. Otherwise, explore the max.value.labels argument of read.spss. On Fri, 4 Jul 2003, Silika Tereshchenko wrote:> I have the following problem. I have to import the dataset (survey) from SPSS > into R-programm. By using the "read.spss" the all of variables have been readed > as factor. I need the variables "income" and "age" as numeric for the > regreesion analysis. Could you plese help me.-- 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
Hi Silika, This is what I would do:>df <- read.spss("datafile", to.data.frame=T) >for(i in c("age","income")){ #Add more if you like+ df[[i]] <- as.numeric(df[[i]]) +} /Fredrik On Fri, Jul 04, 2003 at 08:39:07AM +0200, Silika Tereshchenko wrote:> Hoy, > > > I have the following problem. I have to import the dataset (survey) from SPSS > into R-programm. By using the "read.spss" the all of variables have been readed > as factor. I need the variables "income" and "age" as numeric for the > regreesion analysis. Could you plese help me. > > > Thanks a lot, > best regards, > Silika > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help