+ Reply to Thread
Results 1 to 6 of 6

Thread: Problem with Splus plot function

  1. #1
    Points: 2,242, Level: 28
    Level completed: 62%, Points required for next Level: 58

    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with Splus plot function



    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.

  2. #2
    Super Moderator
    Points: 14,607, Level: 78
    Level completed: 40%, Points required for next Level: 243
    bugman's Avatar
    Posts
    1,492
    Thanks
    88
    Thanked 140 Times in 109 Posts
    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

  3. #3
    Points: 2,242, Level: 28
    Level completed: 62%, Points required for next Level: 58

    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  4. #4
    Super Moderator
    Points: 14,607, Level: 78
    Level completed: 40%, Points required for next Level: 243
    bugman's Avatar
    Posts
    1,492
    Thanks
    88
    Thanked 140 Times in 109 Posts
    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

  5. #5
    Points: 2,242, Level: 28
    Level completed: 62%, Points required for next Level: 58

    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  6. #6
    Points: 2,242, Level: 28
    Level completed: 62%, Points required for next Level: 58

    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

+ Reply to Thread

Similar Threads

  1. Replies: 7
    Last Post: 12-05-2011, 10:55 AM
  2. line plot problem
    By mcquilla in forum SAS
    Replies: 0
    Last Post: 01-10-2010, 07:22 AM
  3. How to plot this function?
    By janeturner in forum R
    Replies: 3
    Last Post: 04-20-2009, 01:24 PM
  4. Splus coding problem
    By curquht in forum R
    Replies: 2
    Last Post: 03-16-2008, 03:55 PM
  5. problem graphing a stat plot....
    By Parsistamon in forum Statistics
    Replies: 0
    Last Post: 09-16-2007, 09:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats