Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert function variable into graph title

Tags:

plot

r

graphics

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?

like image 885
Elizabeth Avatar asked Jun 26 '12 11:06

Elizabeth


1 Answers

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.

like image 141
plannapus Avatar answered Oct 18 '22 07:10

plannapus