[R] How to include factor levels into plot title?

Bea GD aguitatierra at hotmail.com
Wed Jul 9 17:24:02 CEST 2014


Hi all,

I'd like to include the levels of one of my variables in the title of a 
plot. I'd like these factor levels to be concatenated. E.g. 'These are 
the levels: setosa, versicolor, virginica'.

I've been working with this code but I don't get the desired results. 
Any suggestions would be a great help. Thanks!

dd <- iris

plot(dd$Sepal.Length, dd$Petal.Length,
      main=sprintf("These are the levels: %s", levels(dd$Species)))



More information about the R-help mailing list