Re: [R] Multiline and grouping in R

From: ONKELINX, Thierry <Thierry.ONKELINX_at_inbo.be>
Date: Wed, 30 Jun 2010 13:56:56 +0200

Or you could use ggplot2

library(ggplot2)
Dataset <- read.csv("file.csv", header=TRUE) ggplot(Dataset, aes(x = YEAR, y = CASES, colour = AREA)) + geom_line()

HTH, Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
Thierry.Onkelinx_at_inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey   

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] Namens Jim Lemon
> Verzonden: woensdag 30 juni 2010 13:33
> Aan: Pablo Cerdeira
> CC: r-help_at_r-project.org
> Onderwerp: Re: [R] Multiline and grouping in R
>
> On 06/30/2010 10:42 AM, Pablo Cerdeira 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.
> >
> Hi Pablo,
> Just to give you another option, if your data frame is "pcdf":
>
> library(plotrix)
> newpcmat<-cbind(pcdf$CASES[pcdf$YEAR==1988],
> pcdf$CASES[pcdf$YEAR==1989],
> pcdf$CASES[pcdf$YEAR==1990])
> colnames(newpcmat)<-c("1988","1989","1990")
> rownames(newpcdf)<-c("CONTRACTS","INTERNATIONAL","FAMILY","TAXATION")
> bumpchart(newpcmat,col=1:4,rank=FALSE,
> main="Number of cases by year")
> boxed.labels(rep(2.5,3),c(400,300,200),c(400,300,200))
>
> Jim
>
> ______________________________________________
> R-help_at_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.
>

Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.



R-help_at_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. Received on Wed 30 Jun 2010 - 11:59:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 01 Jul 2010 - 02:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive