Hi, all. I'm trying to automate some regression operations in R leaving the possibility to modify the predictors in the regression. For example, I have saved in a list the results and then exported as a txt file, in which we can modify the predictors, putting for example lm(y~x^2) instead of having lm(y~x) as in the original model. Now, I need to import in R the txt file as a list to evaluate the model. Is that possible? I played around with source() and file() but can't figure it out. Thanks. Grazia ---- M. Grazia Pittau, Ph.D. Post-Doctoral Research Fellow Department of Statistics Columbia University 1255 Amsterdam Avenue New York, NY 10027 grazia at stat.columbia.edu Phone: 212.851.2160 Fax: 212.851.2164
?dump ?source But do you really need to save the fitted object as a txt file? Saving/loading it in native format (?save ?load) and then using ?update would seem to be more straightforward. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of > grazia at stat.columbia.edu > Sent: Wednesday, May 10, 2006 8:24 AM > To: R-help at stat.math.ethz.ch > Subject: [R] importing a list > > Hi, all. > I'm trying to automate some regression operations in R leaving the > possibility to modify the predictors in the regression. > > For example, I have saved in a list the results and then > exported as a txt > file, in which we can modify the predictors, putting for example > lm(y~x^2) instead of having lm(y~x) as in the original model. > > Now, I need to import in R the txt file as a list to evaluate > the model. > Is that possible? > > I played around > with source() and file() but can't figure it out. > > Thanks. > Grazia > > ---- > M. Grazia Pittau, Ph.D. > Post-Doctoral Research Fellow > Department of Statistics > Columbia University > 1255 Amsterdam Avenue > New York, NY 10027 > > grazia at stat.columbia.edu > Phone: 212.851.2160 > Fax: 212.851.2164 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
Hello Grazia, On May 10, 2006, at 10:23 AM, grazia at stat.columbia.edu wrote:> I'm trying to automate some regression operations in R leaving the > possibility to modify the predictors in the regression. > > For example, I have saved in a list the results and then exported > as a txt > file, in which we can modify the predictors, putting for example > lm(y~x^2) instead of having lm(y~x) as in the original model. > > Now, I need to import in R the txt file as a list to evaluate the > model. > Is that possible? > > I played around with source() and file() but can't figure it out.What OS are you using? When you say the list is in a text file, how is the text file structured, e.g. CSV, TSV, fixed-width, other? Here's an example of creating, writing, and reading a data.frame: d <- data.frame(cbind(x=1, y=1:10)) write.table(d, file="r-data.txt", sep="\t", na="", quote=FALSE, row.names = FALSE) d.new <- read.delim("r-data.txt") HTH. Regards, - Robert http://www.cwelug.org/downloads Help others get OpenSource software. Distribute FLOSS for Windows, Linux, *BSD, and MacOS X with BitTorrent