[R] Adding lines in ggplot2
Bert Gunter
gunter.berton at gene.com
Wed Jan 5 05:39:43 CET 2011
Dennis:
Can't speak to ggplot2, but your comments regarding lattice are not
quite correct. Many if not all of lattice's basic plot functions are
generic, which means that one has essentially complete latitude to
define plotting methods for arbitrary data structures. For example,
there is an xyplot.ts method for time series -- class ts -- data.
Of course, for most lattice methods, the data do naturally come in a
data frame, and a standard lattice argument is to give a frame from
which to pull the data. But this is not required.
-- Bert
>
> Please explain to me how
>
> df <- data.frame(x, y, index = 1:10)
> qplot(index, x, geom = 'line', ...)
>
> is 'very restrictive'. Lattice and ggplot2 are *structured* graphics systems
> - to get the gains that they provide, there are some costs. I don't perceive
> organization of data into a data frame as being restrictive - in fact, if
> you learn how to construct data for input into ggplot2 to simplify the code
> for labeling variables and legends, the data frame requirement is actually a
> benefit rather than a restriction. Moreover, one can use the plyr and
> reshape(2) packages to reshape or condense data frames to provide even more
> flexibility and freedom to produce ggplot2 and lattice graphics. In
> addition, the documentation for ggplot2 is quite explicit about requiring
> data frames for input, so it is behaving as documented. The complexity (and
> interaction) of the graphics code probably has something to do with that.
>
> Since Josh left you a quote, I'll supply another, from Prof. Steve Vardeman
> in a class I took with him a long time ago:
> "There is no free lunch in statistics: in order to get something, you've got
> to give something up."
>
> In this case, if you want the nice infrastructure provided by ggplot2, you
> have to create a data frame for input.
>
> Dennis
>
>>
>> Thanks in advance, and best regards!
>>
>> Eduardo Horta
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
Bert Gunter
Genentech Nonclinical Biostatistics
More information about the R-help
mailing list