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)?
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 at 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 at 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]]
Hi Glenn, I think it may be your column names. When I substitute the following for the last three sections of your example, I get a plot that looks correct. Obviously I have just made up the colors. colnames(BO.Vector) <- c("LoanAge", "minus05", "minus04", "minus03", "minus02", "minus01") plot(BO.Vector$LoanAge,BO.Vector$minus05,type="l",col=5) lines(BO.Vector$LoanAge,BO.Vector$minus04,col=4) lines(BO.Vector$LoanAge,BO.Vector$minus03,col=3) lines(BO.Vector$LoanAge,BO.Vector$minus02,col=2) lines(BO.Vector$LoanAge,BO.Vector$minus01,col=1) Jim On Mon, Mar 16, 2015 at 8:41 AM, Thierry Onkelinx <thierry.onkelinx at inbo.be> wrote:> 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 at 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 at 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]] > > ______________________________________________ > R-help at 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]]