[R] stuck on making a line graph across time, with 4 categories

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Fri Jun 27 10:59:48 CEST 2008

A solution with ggplot2 would be

dataset <- data.frame(cat = factor(rbinom(1000, 1, prob = .33), labels =
LETTERS[1:2]), startyear = floor(runif(1000, 2001, 2009)), studentid =

ggplot(dataset, aes(x = startyear, colour = cat)) + stat_bin(aes(y =
..count..), geom="line", breaks = 2000:2008 + 0.5)



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
tel. + 32 54/436 185
Thierry.Onkelinx op 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
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org]
Namens Christopher W. Ryan
Verzonden: donderdag 26 juni 2008 21:18
Aan: r-help op stat.math.ethz.ch
Onderwerp: [R] stuck on making a line graph across time, with 4

I can't seem to find just what I'm looking for in R help, Everitt and
Hothorn HSAUR, Murrell's book, or the R graphics gallery at
http://addictedtor.free.fr/graphiques/.  Probably not looking
efficiently, but anyway,

If my data look like this:

> head(data)
      cat startyear studentid
1   other      2001        12
2     UHS      2001        17
3 Lourdes      2001        10
4 Endwell      2001         3
5   other      2002        13
6     UHS      2002        19

What is the easiest way to make a line graph like this (made this one in


Thank you.

Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY  13790
PGP public keys available at http://home.stny.rr.com/ryancw/

"If you want to build a ship, don't drum up the men to gather wood,
divide the work and give orders. Instead, teach them to yearn for the
vast and endless sea."  [Antoine de St. Exupery]

R-help op r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list