See comments inline > -----Original Message----- > From: [email protected] [mailto:r-help-bounces@r- > project.org] On Behalf Of Mick Cooney > Sent: Thursday, November 01, 2012 9:23 AM > To: Greg Snow > Cc: [email protected]; Eva Prieto Castro > Subject: Re: [R] Problem with lm > > But the 'y' is a parameter to the function, so does this mean that the > error is occurring when the function is invoked without that > parameter?
We haven't seen the actual call to the function, singleCosinor(), in your code so we can't say for sure what the problem is. However, the confusion may be that while there is a formal parameter named y, it does not refer to any variable named y in the global environment. If you have a variables t and y in the global environment, then the call would need to be singleCosinor(t=t, y=y) 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 > > On 1 November 2012 16:02, Greg Snow <[email protected]> wrote: > > Yes, it is most likely due to scoping. It is safest to create a data > > frame with all the data in it, then pass that to the data argument of > > lm. > > > > On Thu, Nov 1, 2012 at 2:25 AM, Eva Prieto Castro > <[email protected]> wrote: > >> Hi, > >> > >> I have a problem in relation with a packahe I made. It runs on my > machine (Windows, where I made the package), and it runs in a Mac > machine, but it does not run in another Mac machine with the same R > version. > >> > >> The part of the code is giving problems: > >> > >> singleCosinor <- function(t, y, period=24) { > >> x1 <- cos(2 * pi * t / period) > >> x2 <- sin(2 * pi * t / period) > >> single <- lm (y ~ x1 + x2) > >> return(single) > >> } > >> > >> The error: > >> > >> Error en eval(expr, envir, enclos) : objeto 'y' no encontrado > >> > >> Can it be in relation with scoping?. > >> > >> Thanks in advance. > >> > >> Eva > >> > >> [[alternative HTML version deleted]] > >> > >> > >> ______________________________________________ > >> [email protected] 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. > >> > > > > > > > > -- > > Gregory (Greg) L. Snow Ph.D. > > [email protected] > > ______________________________________________ [email protected] 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.

