Dear users, I think my questions are pretty simple, but I got lost in the hundreds of par() and plot() arguments and plot functions, so I don't know in which direction I should go.
Here is my sample dataset: test <- structure(list(DIET = structure(c(1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L), .Label = c("G", "GG", "L", "LG"), class = "factor"), SILIKATG = c(0.0152, 0.0161, 0.0141, 0.0131, 0.0108, 0, 0, 0, 0, 1e-04, 0.0056, 0.0078, 0.0072, 0.0047, 0.0091, 3e-04, 5e-04, 0, 0.0013, 0.0012)), .Names = c("DIET", "SILIKATG"), row.names = c(1L, 2L, 3L, 4L, 5L, 31L, 32L, 33L, 34L, 35L, 61L, 62L, 63L, 64L, 65L, 101L, 102L, 103L, 104L, 105L), class = "data.frame") 1. The first plot I want to do is: plot(test$SILIKATG, ylim=c(0,0.02), type="l") It looks the way I want to, but my question is:* How to change the labels on the x-axis? I would like to have the groups ("G", "GG", "L", "LG") labeled on the x-axis instead of the "5", "10", "15", "20" of "Index". And if possible with ticks to delimit the groups. * I've tried: plot(test$SILIKATG~test$DIET, ylim=c(0,0.02), type="l") But I get boxplots... 2. The second graph is an alternative, and I would like to use both for now: I first modify the data: selectG <- test[test$DIET=="G",]; selectG$DIET <- factor(selectG$DIET, levels="G") I do it for each group and: plot(selectG$SILIKATG, type="p", ylim=c(0,0.02), pch=1, col="black"); points(selectGG$SILIKATG, type="p", ylim=c(0,0.02), pch=2, col="red") And so on for each group, and then add the legend with: legend(x="topright", legend=c("G", "GG", "L", "LG"), pch=1:4, col=c("black", "red", "green", "blue")) My question here is: * Isn't there an easier way to do all of it?! I'm quite sure there's a way where I don't have to select each group and plot it separately. And I guess something more automatic also exists (e.g. the legend so that I don't have to give the names of the groups and the colors and symbols used etc). *Thank you all in advance for your help. Regards, Ivan -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]]
______________________________________________ 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.