Hey Math Daddy
Remove the closed brackets after function so the braces enclose the script and see how this goes. I just run this through R and I get cooks distances etc and no warnings.
cheers
Phil
Hello.
I am having a problem with the plot function. When I try to plot a linear regression formula, all of the plots show up except the Cook's Distance (which I don't want anyway) and the following error is displayed:
Problem in eval(oc, list()): Object "Dat" not found
Use traceback() to see the call stack
Dat is just a data.frame object that the vectors involved in the regression are coming from. I don't understand why it isn't found, since none of the other graphs should be produced if this is really the case. The following is a minimal working example:
temp <- function()
{
temp1 <- runif(n = 100,min = 0, max = 10)
temp2 <- temp1 + rnorm(n = 100,mean = 0, sd = 1)
temp3 <- as.factor(temp2 < 0)
lin <- lm(temp1 ~ temp2 + temp3)
plot(lin)
}
Since I'm not using a data.frame here, the error message is a little different, but essentially still says that the object temp3 cannot be found. I would appreciate any help.
Thank you very much.
Hey Math Daddy
Remove the closed brackets after function so the braces enclose the script and see how this goes. I just run this through R and I get cooks distances etc and no warnings.
cheers
Phil
Hey Phil.
Thanks for the suggestion. Unfortunately, the script doesn't compile if I remove the braces. Not sure what's causing this problem. Any help would be appreciated.
Thank you very much.
Leave the braces in follwing function and remove () preceeding function:
This works perfectly from my end:
temp <- function
{
temp1 <- runif(n = 100,min = 0, max = 10)
temp2 <- temp1 + rnorm(n = 100,mean = 0, sd = 1)
temp3 <- as.factor(temp2 < 0)
lin <- lm(temp1 ~ temp2 + temp3)
plot(lin)
}
Phil
If I remove the round braces () from the script I get the following error when I try to compile:
Problem in parse(text = "script.run(exprs.literal={\ntemp..: Syntax error: illegal "{" after "function" on input line 3
Use traceback() to see the call stack
Note that I'm using Splus and not R.
Thank you.
This is what my command line looks like when I run the script above:
> temp()
Problem in eval(oc, list()): Object "temp3" not found
Use traceback() to see the call stack
However, before this bizzare error occurs, 5 of the 6 plots are produced (all except Cook's Distance). What is causing the problem, and how do I fix it?
It may be interesting to note that, if I put this exact code directly into the command line, it works. I would really appreciate any help.
Thank you very much.
Last edited by math_daddy; 08-20-2009 at 03:20 PM.
|
|