[R] automatic selection of object without loop

jim holtman jholtman at gmail.com
Fri Sep 16 14:33:04 CEST 2011


for (i in names(kinderrechte)){
    q1 <- kinderrechte[, i]
    i 1 <- get(i)
}

On Fri, Sep 16, 2011 at 4:47 AM, Marion Wenty <marion.wenty at gmail.com> wrote:
> Hello,
>
> does anyone know the solution to this problem:
>
> I imported a dataframe from Spss into R and saved it as an object called
> "kinderrechte".
>
> I have got the following command lines:
>
> q1 <- kinderrechte[,"q0007_0001"]
> l1 <- q0007_0001_l
>
> now i would like to be able to change the column name in the first command
> line (e.g. into q0007_0002) and to get R to automatically change
> q0007_0001_l in the second command line into q0007_0002_l without using a
> loop.
>
> Thank you in advance for your help!
>
> Marion
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list