It doing exactly what you asked it to do. You have the assignment: result <- latentVariableNames
and then you print it out in the loop. What were you expecting? On Wed, Feb 10, 2010 at 9:06 PM, Chaehan So <chaehan...@gmail.com> wrote: > Dear r-helpers, > > why do I get an output in the first iteration of the for-loop > which contains the string values of the input vector, > and how can I avoid that? > > Here's the output (only line 1 is wrong) > > latentVariable Indiv Group > 1 rPlanning rIterat rTDD > 2 rPlanning 0.79 0.84 > 3 rIterat 0.79 0.83 > 4 rTDD 0.9 0.96 > 5 rStandup 0.83 0.82 > 6 rRetros 0.9 0.95 > 7 rAccess 0.91 0.92 > 8 rAccTest 0.87 0.9 > > ##### > LV <- c("rPlanning", "rIterat", "rTDD", "rStandup", "rRetros", "rAccess", > "rAccTest") > ##### > loopCronbach <- function(latentVariableNames, groupingVariable) > { > result <- latentVariableNames > names(result) <- c("latentVariable", "Indiv", "Group") > for (currentName in latentVariableNames) > { > print(currentName) > print(result) > tmp1 <- calculateIndividualCronbach(get(currentName)) > tmp2 <- calculateGroupCronbach(get(currentName), groupingVariable) > result <- rbind(result,data.frame(latentVariable=currentName, > Indiv=tmp1,Group=tmp2)) > } > return(result) > } > > > a <- loopCronbach(LV, u_proj) > > [[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 Cincinnati, OH +1 513 646 9390 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.