I agree with Daniel J. Nordlund that the problem must be that you are not attaching the data to directly access x and y. Try to do that with attach(data_model.df) right after reading the data.
Talita 2009/4/15 x <to_rent_2...@yahoo.com> > > I forgot to show that my file indeed contains x, y values: > > x y > 1 8.2 > 2 18 > 3 -17.6 > 4 -3.4 > 5 6.8 > 6 11.3 > 7 1.5 > 8 11 > 9 -3.3 > 10 8.1 > > > --- On Wed, 4/15/09, x <to_rent_2...@yahoo.com> wrote: > > > From: x <to_rent_2...@yahoo.com> > > Subject: RE: [R] problem with read.table > > To: r-help@r-project.org, "Nordlund, Dan (DSHS/RDA)" < > nord...@dshs.wa.gov> > > Date: Wednesday, April 15, 2009, 5:09 PM > > Thank you for the reply. That format works but since I need > > access to x, y subsequent to lm() also, I tried the > > following but now I'm back to the same old error message > > of "object y not being found". > > > > data_model.df = read.table("./verify.txt", > > header=TRUE, nrows=10); > > dd = datadist(data_model.df); > > options(datadist = 'dd'); > > describe(data_model.df); > > > > f <- lm(y ~ x) > > print( summary(f) ) > > > > plot(x, y) > > > > I tried without "options" and > > "describe" and still the same problem. > > > > Thanks again! > > > > > > --- On Wed, 4/15/09, Nordlund, Dan (DSHS/RDA) > > <nord...@dshs.wa.gov> wrote: > > > > > From: Nordlund, Dan (DSHS/RDA) > > <nord...@dshs.wa.gov> > > > Subject: RE: [R] problem with read.table > > > To: to_rent_2...@yahoo.com, r-help@r-project.org > > > Date: Wednesday, April 15, 2009, 5:01 PM > > > > -----Original Message----- > > > > From: r-help-boun...@r-project.org > > > [mailto:r-help-boun...@r-project.org] On > > > > Behalf Of x > > > > Sent: Wednesday, April 15, 2009 1:54 PM > > > > To: r-help@r-project.org > > > > Subject: [R] problem with read.table > > > > > > > > > > > > Hi all, > > > > > > > > I've simple code to read a file (verify.txt > > in the > > > same directory as the script file) but > > > > when I run this I get > > > > "Error in eval(expr, envir, enclos) : object > > > "y" not found". > > > > > > > > data_model.df = > > read.table("./verify.txt", > > > header=TRUE, nrows=10); > > > > f <- lm(y ~ x) > > > > > > > > Could someone pls tell me what's wrong with > > this > > > code? > > > > > > > > Sincere thanks! > > > > > > I don't think there is a problem with > > read.table(). > > > You need to attach the dataframe or specify > > > data=data_model.df in the call to lm() > > > > > > f <- lm(y ~ x, data = data_model.df) > > > > > > Hope this is helpful, > > > > > > Dan > > > > > > Daniel J. Nordlund > > > Washington State Department of Social and Health > > Services > > > Planning, Performance, and Accountability > > > Research and Data Analysis Division > > > Olympia, WA 98504-5204 > > ______________________________________________ > 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. > -- Talita Perciano Instituto de Matemática e Estatísitca Universidade de São Paulo - USP PhD Student in Computer Science São Paulo, SP, Brazil Tel: +55 11 8826 7092 "Success is not final, failure is not fatal: it is the courage to continue that counts." (Winston Churchill) [[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.