Owo! Many thanks to you all. A lot of answers in just a few minutes!! I'd like to thank you Dennis, Joshua, David, Erik and Bill.
I'll try these solutions and read something about xyplot. Best regards to you. On Tue, Jun 29, 2010 at 10:54 PM, Dennis Murphy <djmu...@gmail.com> wrote: > Hi: > > This is to add a couple of bells and whistles to the excellent replies of > David and Bill. You may not want the 0.5 increments in the x-axis ticks, and > if you want all groups in a single plot, then you may want a legend. Below > are some basic ways to specify these (to head off the obvious follow-up > questions :) > > # (1) Individual panels per AREA: > xyplot(CASES ~ YEAR|AREA, data=df, type="b", > scales = list(x = list(at = c(1988, 1989, 1990)))) > > The scales = argument provides control over various aspects of the axes, > such as labels and tick marks. In this case, we want to limit the x-axis > ticks to occur at 1988, 1989 and 1990 only. > > # (2) Single graph with multiple AREA profiles over time: > xyplot(CASES ~ YEAR, data = df, type = "b", groups = AREA, > scales = list(x = list(at = c(1988, 1989, 1990))), > auto.key = list(points = FALSE, lines = TRUE)) > > The auto.key = argument is used to produce a simple legend. By default, it > is listed on top of the plot; if, for example, you wanted it on the right > instead, you could add space = 'right' to the auto.key list. > > There are **many** options in xyplot() and other Lattice graphics > functions, so you have the capability of fine tuning a graph to meet your > specifications. > > HTH, > Dennis > > > On Tue, Jun 29, 2010 at 5:42 PM, Pablo Cerdeira > <pablo.cerde...@gmail.com>wrote: > >> Hi All, >> >> this is my first mail here. >> >> I'm trying to plot a multiline chart grouping values with no success. I >> have >> read a lot in the official Wiki and also searched via Google, but I did >> not >> find anything. >> >> I'm importing some data from a cvs file. Here is a sample: >> >> YEAR,AREA,CASES >> 1988,CONTRACTS,286 >> 1988,INTERNATIONAL,189 >> 1988,FAMILY,385 >> 1988,TAXATION,177 >> 1989,CONTRACTS,233 >> 1989,INTERNATIONAL,431 >> 1989,FAMILY,425 >> 1989,TAXATION,201 >> 1990,CONTRACTS,190 >> 1990,INTERNATIONAL,302 >> 1990,FAMILY,303 >> 1990,TAXATION,209 >> ... >> >> "t <- read.csv("file.csv", header=TRUE)" >> >> So far so good... >> >> But the problem is: I'd like to create a multiline plot, one line per >> AREA, >> showing the evolution of the number of CASES per YEAR. >> >> I know how to do it in Excel, using a Pivot Table. But I'm trying hard to >> do >> the same with R but I have no idea on how to do it. >> >> Can someone help me? >> >> Thanks in advanced >> >> -- >> Pablo de Camargo Cerdeira >> pablo.cerde...@gmail.com >> +55 (21) 3799-6065 >> >> [[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. >> > > -- Pablo de Camargo Cerdeira pablo.cerde...@gmail.com +55 (21) 3799-6065 [[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.