[R] Basic ggplot question

Santosh Srinivas santosh.srinivas at gmail.com
Mon Jan 10 14:12:48 CET 2011


Hello R-Group,

I am trying plotting simple time-series with ggplot2 because the output
looks better and I've heard its richer in features.

I have the following dataset.
> dput(dat)
structure(list(Date = structure(c(14970, 14971, 14972, 14973, 
14974, 14977, 14978, 14979, 14980, 14981), class = "Date"), Close =
c(5998.1, 
5996, 6060.35, 6101.85, 6134.5, 6157.6, 6146.35, 6079.8, 6048.25, 
5904.6), vol = c(0.154535414667409, 0.151830297402932, 0.140309395040681, 
0.136253183394409, 0.137108091041075, 0.137109537791588, 0.137664093371524, 
0.141313700592413, 0.123866294210121, 0.139356235990631)), .Names =
c("Date", 
"Close", "vol"), row.names = c("4905", "4906", "4907", "4908", 
"4909", "4910", "4911", "4912", "4913", "4914"), class = "data.frame")

I can get one plot using:
qplot(Date, Close, data=dat,geom="line")

How can I plot both Close and vol on the same chart?

Been breaking my head on this ... thanks for your help in advance.

Regards,
S



More information about the R-help mailing list