[R] multiple graphs with a single legend and trellis graph

Rosa Oliveira rosita21 at gmail.com
Wed Jul 8 14:11:34 CEST 2015


Dear Jim,

first of all, thank you very much :) 
when I run the code:

myDF <- rbind(mse.alpha1, mse.alpha2)  # assumes both data frames have the same variables in the same order


myDF$ID <- factor(rep(c("alpha1", "alpha2"), times =
c(nrow(mse.alpha1), nrow(mse.alpha2))) )   


library(reshape2)
myDF.melt <- melt(myDF, id = c("ID", "nsample", "lambda"), measure =
c("mse.naive", "mse.RegCal", "mse.PL"))  #Melt the three columns to be plotted, something like

library(ggplot2)
ggplot(myDF.melt, aes(x = lambda, y = value, color = variable)) +
   geom_point() + geom_line() +
   facet_grid(ID ~ nsample) +
   labs(x = expression(paste(lambda)), y = "MSE", color = "Type”)



 I get the attached graph. I also attach my data, so you can see :)

I’m I able to resize the graphs differently? I.e. for alpha1: ylim=ylim=c(0,.6) and for alpha2: ylim=c(0,.17)? 
I reshaped, a new variable in sample was created, NA, Was it me that made something wrong?

I’m very naive and new in R :(

Thanks again ;)







Atenciosamente,
Rosa Oliveira

-- 
____________________________________________________________________________


Rosa Celeste dos Santos Oliveira, 

E-mail: rosita21 at gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira
____________________________________________________________________________
"Many admire, few know"
Hippocrates



More information about the R-help mailing list