You have to give more specifications as to what you want to do with the data that is being processed. You have values being put into 'q1' and 'i1' that don't seem to be used in the loop. Do you just want these values returned? You can easily do it "without a loop" using lapply:
result <- lapply(names(kinderrechte), function(.name){ # return a list with the result list(q1 = kinderrechte[, .name], i1 = get(paste(.name, "_l", sep = "") }) So what is the problem that you are trying to solve? On Fri, Sep 16, 2011 at 8:34 AM, jim holtman <jholt...@gmail.com> wrote: > did not see the "_l" so changes below: > > On Fri, Sep 16, 2011 at 8:33 AM, jim holtman <jholt...@gmail.com> wrote: >> for (i in names(kinderrechte)){ >> q1 <- kinderrechte[, i] >> i 1 <- get(paste(i, "_l", sep = "")) >> } >> >> On Fri, Sep 16, 2011 at 4:47 AM, Marion Wenty <marion.we...@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@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? >> > > > > -- > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? ______________________________________________ R-help@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.