[R] Fortune nomination; was Re: (no subject)
David Winsemius
dwinsemius at comcast.net
Tue Jun 24 21:48:25 CEST 2014
On Jun 24, 2014, at 7:52 AM, Jeff Newmiller wrote:
Jeff Newmiller's rhelp/ggplot strategy checklist:
> Reproducibility == good (except for mixing in invalid code and failing to set RNG seed)
> HTML email == bad
> Missing subject == bad
> Using matrices with ggplot == pushing a rope
> Using for loops to build a ggplot == missing the point
> Using wide-form data with ggplot == pushing a rope
--
Best;
David.
>
>
> On Tue, 24 Jun 2014, Zayd Farah wrote:
>
>> I hope the following script is reproducible enough to highlight my issue,
>> which is to automatically (in this case by loop, but it does not
>> necessarily have to be by a loop) add geom_line layers for each column of
>> mydata to the ggplot variable p1. for some reason doing this only works by
>> manually adding each layer:
>>
>> library(ggplot2)
>> library(gtable)
>>
>>
>> #creates set of reproducible data
>> xaxis<-rnorm(30)+10
>> xaxis
>> mydata<-replicate(9, rnorm(30)+20)
>>
>> #creates a matrix of colors to identify each line on the final plot of
>> #each column of mydata
>>
>> colour_scheme<-palette(rainbow(dim(mydata)[2]))
>>
>> # Main scatterplot
>> p1 <- ggplot(NULL)
>>
>> #ideal code that would create a geom_line layer for each column of mydata
>> vs. xaxis
>> for (i in 1:dim(mydata)[2])
>> {
>> p1=p1+geom_line(aes(xaxis,mydata[,i]),colour=colour_scheme[i])
>> }
>> p1
>>
>> #run the following code to see what it SHOULD look like:
>> p1 <- ggplot(NULL)
>> p1=p1+geom_line(aes(xaxis,mydata[,1]),colour=colour_scheme[1])
>> p1=p1+geom_line(aes(xaxis,mydata[,2]),colour=colour_scheme[2])
>> p1=p1+geom_line(aes(xaxis,mydata[,3]),colour=colour_scheme[3])
>> p1=p1+geom_line(aes(xaxis,mydata[,4]),colour=colour_scheme[4])
>> p1
>>
>> [[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.
>>
>
> ---------------------------------------------------------------------------
> Jeff Newmiller The ..... ..... Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
> Live: OO#.. Dead: OO#.. Playing
> Research Engineer (Solar/Batteries O.O#. #.O#. with
> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
>
> ______________________________________________
> 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.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list