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

From: ONKELINX, Thierry <Thierry.ONKELINX_at_inbo.be>
Date: Fri, 27 Jun 2008 10:59:48 +0200

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 = 1:1000)

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

HTH, Thierry




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
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 Christopher W. Ryan
Verzonden: donderdag 26 juni 2008 21:18
Aan: r-help_at_stat.math.ethz.ch
Onderwerp: [R] stuck on making a line graph across time, with 4 categories

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 Stata):

http://bingweb.binghamton.edu/~cryan/Workload.png

Thank you.

--Chris

-- 
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY  13790
cryanatbinghamtondotedu
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_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.

______________________________________________
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 Fri 27 Jun 2008 - 09:02:46 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 Fri 27 Jun 2008 - 09:31:15 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