> I have following data set, which I want to plot the "Scale" variable on the > x-axis and "Mean"´on the y-axis for each Ageclass and for each sex. The Mean > value of each Ageclass for each sex would be connected by a line. Totally, > there should be 6 lines, from which three present the Mean values of each > Ageclass for respective sex. Are there any easy ways to do this in R?
Maybe something like: install.packages("ggplot2") library(ggplot2) qplot(Scale, Mean, data=df, colour=Sex, linetype = Ageclass, geom="line", group=interaction(Sex, Ageclass)) The only possibly non-intuitive thing is the group variable - this specifies the that you want a single line for each combination of sex and ageclass. The default is to draw a line for each combination of all of the categorical variables, which doesn't work here because the x axis is categorical. You might also want to do: df <- transform(df, Scale = reorder(Scale, Mean)) which orders scale in ascending order of mean Mean. You can find out more about ggplot2 at http://had.co.nz/ggplot2 Hadley -- http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.