8

I have a function with two input variables

min.depth<-2  
max.depth<-5

the function produces a plot. How can I insert the input variables into the title?

I have tried:

plot.a<-plot(plt.a$"Traits",plt.a$"Species",xlab="Site similarity by traits (Tsim)",
             ylab="Site similarity by species (Jaccard)",
             main=c("Jaccard vs. Tsim for depths", min.depth, "to",max.depth,"m")

While this does insert the input variable correctly it also causes the title to stack as follows:

Jaccard vs. Tsim for depths  
2  
to  
5  
m 

Any ideas on how to avoid this stacking?

1
  • 1
    Great work at including example code. Now try to make this reproducible, and I shall take a look. If you can't post your own data, try reproducing your problem with the iris data. Commented Jun 26, 2012 at 11:34

1 Answer 1

16

You should use pasteinstead of c:

plot(..., main=paste("Jaccard vs. Tsim for depths",  min.depth, "to",max.depth,"m", sep=" "))

With c you create a vector of strings (hence the stacking), with paste you concatenate them into one single string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.