Hi Bob, You can use the get() function to loopup a variable name.
> long.variable.name <- 5 > "long.variable.name" [1] "long.variable.name" > get("long.variable.name") [1] 5 However, I think this is all overkill. Assuming extractModelParameters() came from the MplusAutomation package, and that the documentation is correct, then it returns a list, ordered in some predictable way. Take advantage of this. I suspect you can get all your code down to something like: lapply(modelResults, `[`, 31) I do not have any Mplus outfiles to toy around with so that code probably will not be it exactly, but the point is, I think you are going to a lot of trouble to create these variable names, and there is probably a much easier way. If you can upload an Mplus file online and email the link, I can probably give you more specific advice. Cheers, Josh On Sat, Dec 11, 2010 at 12:43 PM, vaibhav dua <to_v...@yahoo.com> wrote: > Hi, > > I'm generating the name of the variable with paste function and then using > that > variable name further to get the specific position value from the data.frame, > here is the snippet from my code: > > modelResults <- extractModelParameters("C:/PilotStudy/Mplus_Input/Test", > recursive=TRUE) > > #extractModelParameters reads all the output files from the Test folder and > create the following variables in R for each file read: > #C..PilotStudy.Mplus_Input.Test.rep1.out.unstandardized.est > #C..PilotStudy.Mplus_Input.Test.rep2.out.unstandardized.est > #C..PilotStudy.Mplus_Input.Test.rep3.out.unstandardized.est > > modelResultsTemp <- as.data.frame(modelResults) > > MeansTempC1 = rep(NA ,9) > counter = 1 > > for (f in 1:3) > { > i=31 > > for (g in 1:3) > { > OutputFileName <- > paste("modelResultsTemp$C..PilotStudy.Mplus_Input.Test.rep",f,".out.unstandardized.est[",i,"]",sep="") > > MeansTempC1[counter] = OutputFileName > i=i+1 > counter = counter+1 > } > } > > Its not giving me any error but I'm not getting the desired output in > MeansTempC1 because OutputFileName is a string and thats why its not returning > the OutputFileName[31] etc. Does anybody know how to eliminate the double > quotes > so that I can use the variable name (generated with the paste function) > further > in the code > > Regards > Bob > > > > > [[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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ ______________________________________________ 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.