Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this for zoo classic graphics, zoo lattice graphics and zoo ggplot2 graphics:</p> <pre><code>library(zoo) z &lt;- read.zoo(DT, split = 1, index = 2, FUN = identity) Names &lt;- read.table(text = names(z), sep = ".", col.names = c("screen", "col")) plot(z, screen = Names$screen, col = Names$col) # also see note 3 below library(lattice) xyplot(z, screen = Names$screen, col = Names$col) # also see note 3 below library(ggplot2) # also see note 4 below m &lt;- fortify(z, melt = TRUE) m2 &lt;- transform(m, screen = sub("\\..*", "", Series), col = sub(".*\\.", "", Series)) qplot(Index, Value, data = m2, col = col, geom = "line") + facet_wrap(~ screen) </code></pre> <p><em>Notes</em> </p> <p>1) If we just wanted separate panels it would just be <code>plot(z)</code>, <code>xyplot(z)</code> and <code>autoplot(z)</code>.</p> <p>2) <code>names(z)</code> and <code>Names</code> are:</p> <pre><code>&gt; names(z) [1] "V1.a" "V2.a" "V1.b" "V2.b" "V1.c" "V2.c" &gt; Names screen col 1 V1 a 2 V2 a 3 V1 b 4 V2 b 5 V1 c 6 V2 c </code></pre> <p>3) We could have just hard coded it as this (in which case we would not need <code>Names</code>):</p> <pre><code>plot(z, screen = 1:2, col = c(1, 1, 2, 2, 3, 3)) xyplot(z, screen = 1:2, col = c(1, 1, 2, 2, 3, 3)) </code></pre> <p>4) Here is a ggplot2 alternative not involving <code>z</code>. It converts <code>DT</code> to long form with data.table package and then performs the <code>qplot</code>:</p> <pre><code>long &lt;- DT[, list(Series = names(.SD), Value = unlist(.SD)), by = list(type, time)] qplot(time, Value, data = long, col = type, geom = "line") + facet_wrap(~ Series) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload