Hello R users, I am new to R and am having difficulty with the output of my "for" loops. I have written a function to perform a linear regression on multiple files, but when I use the "print()" function to look at my results, it is not specified from which data set the regression was done on. I would like the output from my for loops to specify which data set the regression corresponds to. The following code following this text is an example of what I used to perform the regression. I would like my output from the loop to label each regression based on the data used for the analysis.
Thank-you for your help Kevin Long Example Code: setwd("/Users/kevinlong/Desktop/R Example") list <- list.files() for (x in list) {u <- read.table(x,header = T, sep=",") regression <- lm(u$R~u$T) print(regression) } -- Kevin Long, M.Sc. Environmental Science Technician University of Calgary Phone: (403) 804-6855 [[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.