Re: [R] Line plots in base graphics

2011-04-13 Thread Ben Bolker
Hadley Wickham hadley at rice.edu writes:

 
 Am I missing something obvious on how to draw multi-line plots in
 base graphics?
 
 In ggplot2, I can do:
 
data(Oxboys, package = nlme)
library(ggplot2)
 
qplot(age, height, data = Oxboys, geom = line, group = Subject)
 
 But in base graphics, the best I can come up with is this:
 
with(Oxboys, plot(age, height, type = n))
lapply(split(Oxboys[c(age, height)], Oxboys$Subject), lines)

[quoting removed to fool gmane] 
 Am I missing something obvious?
 

 reshape to wide format and matplot()?

__
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.


Re: [R] Line plots in base graphics

2011-04-13 Thread Hadley Wickham
On Wed, Apr 13, 2011 at 2:58 PM, Ben Bolker bbol...@gmail.com wrote:
 Hadley Wickham hadley at rice.edu writes:


 Am I missing something obvious on how to draw multi-line plots in
 base graphics?

 In ggplot2, I can do:

 data(Oxboys, package = nlme)
 library(ggplot2)

 qplot(age, height, data = Oxboys, geom = line, group = Subject)

 But in base graphics, the best I can come up with is this:

 with(Oxboys, plot(age, height, type = n))
 lapply(split(Oxboys[c(age, height)], Oxboys$Subject), lines)

 [quoting removed to fool gmane]
 Am I missing something obvious?


  reshape to wide format and matplot()?

Hmmm, that doesn't work if your measurements are at different times e.g:

Oxboys2 - transform(Oxboys, age = age + runif(234))

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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.


Re: [R] Line plots in base graphics

2011-04-13 Thread Ben Bolker
Hadley Wickham hadley at rice.edu writes:

 On Wed, Apr 13, 2011 at 2:58 PM, Ben Bolker bbolker at gmail.com wrote:
  Hadley Wickham hadley at rice.edu writes:
 
 
  Am I missing something obvious on how to draw multi-line plots in
  base graphics?

 [snip]

  But in base graphics, the best I can come up with is this:
 
  with(Oxboys, plot(age, height, type = n))
  lapply(split(Oxboys[c(age, height)], Oxboys$Subject), lines)
 
  [quoting removed to fool gmane]
  Am I missing something obvious?
 
   reshape to wide format and matplot()?
 
 Hmmm, that doesn't work if your measurements are at different times e.g:
 
 Oxboys2 - transform(Oxboys, age = age + runif(234))

   In that case I think you're stuck with your lapply() approach,
or (I think) using lattice graphics with the group= argument
(that's not base though).

  Ben

__
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.


Re: [R] Line plots in base graphics

2011-04-13 Thread baptiste auguie
On 14 April 2011 07:51, Hadley Wickham had...@rice.edu wrote:
 Am I missing something obvious on how to draw multi-line plots in base 
 graphics?

 In ggplot2, I can do:

It appears you've been infected with what I like to call the Dijkstra
syndrome [*], quoting

The tools we use have a profound (and devious!) influence on our
thinking habits, and, therefore, on our thinking abilities.

You can probably blame ggplot2 here, messing with our minds and
spoiling us. I can't seem able to think like spreadsheets anymore
either, because of R.

Thanks though,

baptiste


[*] http://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html


 data(Oxboys, package = nlme)
 library(ggplot2)

 qplot(age, height, data = Oxboys, geom = line, group = Subject)

 But in base graphics, the best I can come up with is this:

 with(Oxboys, plot(age, height, type = n))
 lapply(split(Oxboys[c(age, height)], Oxboys$Subject), lines)

 Am I missing something obvious?

 Thanks!

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

 __
 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.


__
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.