[R] assignment of inidividual variables from spss save files
Romain Francois
francoisromain at free.fr
Mon Jun 13 09:47:36 CEST 2005
Le 13.06.2005 09:22, Mike Day a écrit :
>New to R, can't afford SPSS!
>
>Why can't I assign spss variables? Here are the details.
>
> > ### I've read in my collaborator's sav file using read.spss, eg
> > children = read.spss(filename)
> > ### It has many variables
> > length(children)
>[1] 347
> > ### and I would like to assign individual variables.
> > ### I can of course type out all the ones I want, eg
> > ADULTS11<-children[18]
> > ### But I'm lazy, so tried:
> > (function (x,n){assign(names(x[n]),x[n])})(children,2)
> > ### where
> > names(children[2])
>[1] "ADNUTS06"
> > ### but
> > ADNUTS06
>Error: Object "ADNUTS06" not found
> > ### I've tried lots of variations, including creating and
> > ### evaluating statements such as "ADNUTS06<-children[2]",
> > ### but without apparently yielding the required variable.
>
>I expect the answer will be "You shouldnt start from here!"
>Ideas welcome.
>
>Thanks, Mike
>
>
?attach may be what you are looking for
--
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
~~~~~~ Romain FRANCOIS - http://addictedtor.free.fr ~~~~~~
~~~~ Etudiant ISUP - CS3 - Industrie et Services ~~~~
~~ http://www.isup.cicrp.jussieu.fr/ ~~
~~~~ Stagiaire INRIA Futurs - Equipe SELECT ~~~~
~~~~~~ http://www.inria.fr/recherche/equipes/select.fr.html ~~~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
More information about the R-help
mailing list