[R] ggplot2 help

Thierry Onkelinx thierry.onkelinx at inbo.be
Sun Mar 15 22:41:12 CET 2015


I can't reproduce the problem with your code. I just get an error because
cbbPalette is not available. Omitting the scale_colour_manual() form your
code give a sensible plot.

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-03-15 20:35 GMT+01:00 Glenn Schultz <glennmschultz op me.com>:

> All,
>
> I am doing something wrong but I don't see what.  When I plot in ggplot
> all the lines are on top of one another but the data is not.  Any help is
> appreciated.
>
> Thanks,
> Glenn
>
> # -------- I use this function to generate data
> Burnout <- function(beta1 = numeric(),
>                       beta2= numeric(),
>                       MaxIncen = numeric(),
>                       LoanAge = numeric()){
>   exp(beta1 * LoanAge +  beta2 * MaxIncen)}
>
> # -------------------- Build the data frame for plotting
>   BO.Vector <- data.frame(c(seq(1,360,1)))
>   BO.Vector[,2] <- cbind(Burnout(beta1 = -.05, beta2 = 0, MaxIncen = 25,
> LoanAge = BO.Vector[,1]))
>   BO.Vector[,3] <- cbind(Burnout(beta1 = -.04, beta2 = 0, MaxIncen = 25,
> LoanAge = BO.Vector[,1]))
>   BO.Vector[,4] <- cbind(Burnout(beta1 = -.03, beta2 = 0, MaxIncen = 25,
> LoanAge = BO.Vector[,1]))
>   BO.Vector[,5] <- cbind(Burnout(beta1 = -.02, beta2 = 0, MaxIncen = 25,
> LoanAge = BO.Vector[,1]))
>   BO.Vector[,6] <- cbind(Burnout(beta1 = -.01, beta2 = 0, MaxIncen = 25,
> LoanAge = BO.Vector[,1]))
>
>   colnames(BO.Vector) <- c("LoanAge", "-.05", "-.04", "-.03", "-.02",
> "-.01")
>   colnames(BO.vector) <- c("LoanAge", "-.05", "-.04")
>
> # ------------------- reshape 2 prepare for ggplot2
>   BO.Vector <- melt(BO.Vector, id = "LoanAge")
>
>
> # --------------- plot (not working)
>   ggplot(BO.Vector, aes(x= LoanAge, y = value, color = variable, linetype
> = variable)) +
>   geom_line()+
>   theme_minimal() +
>   labs(colour = "Legend", linetype = "Legend", x = "Loan Age", y =
> "Burnout") +
>   theme(panel.grid.major = element_line(size = .25, color = "grey")) +
>   theme(axis.text = element_text(size = 15)) +
>   theme(axis.title = element_text(size = 20)) +
>   theme(legend.position = c(.9, .4)) +
>   scale_colour_manual(values = cbbPalette)
>
>
> ______________________________________________
> R-help op r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]



More information about the R-help mailing list