Include plot title in R

Hello,

I am attempting to include a title on a scatterplot in R. I am able to run the code directly below for creating the plot just fine:

pnf2.resid0 <- residuals(pnf2.glmssn0)
names( getSSNdata.frame(pnf2.resid0) )
plot(pnf2.resid0)

Open in new window


However, when I attempt to add a title using main = (as shown below), I receive an error message that reads: "formal argument 'main' matched by multiple actual arguments"

pnf2.resid0 <- residuals(pnf2.glmssn0)
names( getSSNdata.frame(pnf2.resid0) )
plot(pnf2.resid0, main = "Residual Plot")

Open in new window


Any suggestions for how to include a title on the plot?
LVL 1
dougf1rAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

d-glitchCommented:
Looks correct.  Try getting rid of the spaces around the equal sign.
0
dougf1rAuthor Commented:
I get the same error after removing the spaces.

The problem seems to have something to do with having .resid0 after pnf2. I get the same error when attempting to add a title to a histogram. The first histogram function (shown below) works fine. However, the second fails with the same error.

par(mfrow = c(1, 2))
hist(pnf2, "Response", main = "Spatial")
hist(pnf2.resid_dn)

Open in new window

0
dougf1rAuthor Commented:
...that is, the second histogram function fails if I try adding , main = "Residual Plot" to the function.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

trinitrotolueneDirector - Software EngineeringCommented:
try using title()

plot(pnf2.resid_0)
title(main="Residual Plot", col.main="red", font.main=4)

Open in new window

0
dougf1rAuthor Commented:
Using title() as a separate function does include a title at the top of the page. However, the plot includes a default title and this default title remains on the plot, so there are now two titles (attached).
0
dougf1rAuthor Commented:
Attachment for comment above.
Rplot.jpeg
0
trinitrotolueneDirector - Software EngineeringCommented:
This is probably the reason why the first error happened. Let me check this out and I'll let you know.

Can you upload the whole source file. I would like to see how you are initializing
0
trinitrotolueneDirector - Software EngineeringCommented:
you also need to give the complete error message. Pretty difficult seeing where the argument matching is going awry without this info
0
trinitrotolueneDirector - Software EngineeringCommented:
plot(pnf2.resid0, main = "Residual Plot")

Open in new window


looking at your original code. You are defining main to be "Res....Plot"

If you trace into the plot call there will already exist a definition for main and that is the reason you are getting the multiple arguments error.
I suspect main is being set to the default string you uploaded in your last post.


Hope this helps.

Else just upload your whole source file and the whole error message. Use traceback() to get the whole call sequence leading up to the error
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dougf1rAuthor Commented:
yes. this helps. thank you for the helpful comments. I can get it working now.
0
trinitrotolueneDirector - Software EngineeringCommented:
Glad it worked. Could you show me the code  you put in to fix the problem.?
Just the relevant snippet should do.
Interested from a technical angle.
0
dougf1rAuthor Commented:
Your comment and suggestion of using traceback() to get the whole call sequence leading up to the error is a sufficient answer to my question. However, I am occupied by other tasks at the moment, so I am not able to implement the solution at this time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Theory

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.