Insert a function variable into the graph header in R

I have a function with two input variables

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

function creates a graph. How to insert input variables in the header?

I 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 correctly inserts the input variable, it also causes the header to add up as follows:

Jacquard vs Tsim for depths
2
for 5
m image

Any ideas on how to avoid this styling?

+5
source share
1 answer

You should use pasteinstead c:

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

With the help of cyou create a vector of lines (hence the styling), and pastecombine them into one line.

+8

All Articles