[R] Help
Uwe Ligges
ligges at statistik.uni-dortmund.de
Mon Jul 7 10:58:16 CEST 2003
Silika Tereshchenko wrote:
> Dear all,
>
>
>
> I have the problem, please, help me. I tried to import the dataset from the SPSS
> into the R. It is the panel (survey). The importing of the data show that my
> variables are read as afactor in R. But I need the variable "income" as a
> numeric one. I tried to use the following command:
>
> for(i in
> c("AGE99","AGE00","I99PTOT","I00PTOT","I99PTOTN","I00PTOTN","I99PTOTG","I00PTOTG"))
> + {df[[i]]<-as.numeric(df[[i]])}
>
> and then I get the error message.
> Error in "[[<-.data.frame"(*tmp*, i, value = as.numeric(df[[i]])) :
> replacement has 1 rows, data has 6335
>
> What can I do? Could you please help me. I need it for my work.
Is df really a data.frame? Can you tell us about its structure using
str(df)? What is your version of R?
Your statement works for me with a simple example of df[[i]].
Uwe Ligges
> Dear all,
>
>
>
> I have the problem, please, help me. I tried to import the dataset from the SPSS
> into the R. It is the panel (survey). The importing of the data show that my
> variables are read as afactor in R. But I need the variable "income" as a
> numeric one. I tried to use the following command:
>
> for(i in
> c("AGE99","AGE00","I99PTOT","I00PTOT","I99PTOTN","I00PTOTN","I99PTOTG","I00PTOTG"))
> + {df[[i]]<-as.numeric(df[[i]])}
>
> and then I get the error message.
> Error in "[[<-.data.frame"(*tmp*, i, value = as.numeric(df[[i]])) :
> replacement has 1 rows, data has 6335
>
> What can I do? Could you please help me. I need it for my work.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list