From a6b60f91ff8d798a3dcb7da6acbc03fba8a0459d Mon Sep 17 00:00:00 2001
From: emilie <emilie@devijver.org>
Date: Wed, 12 Apr 2017 11:45:12 +0200
Subject: [PATCH] few updates

---
 pkg/DESCRIPTION    |  1 +
 pkg/R/main.R       |  2 +-
 pkg/R/plot_valse.R | 11 +++++++----
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION
index 32ed6a8..c975ee9 100644
--- a/pkg/DESCRIPTION
+++ b/pkg/DESCRIPTION
@@ -39,3 +39,4 @@ Collate:
     'EMGLLF.R'
     'generateXY.R'
     'A_NAMESPACE.R'
+    'plot_valse.R'
diff --git a/pkg/R/main.R b/pkg/R/main.R
index 701a2c9..a2e5697 100644
--- a/pkg/R/main.R
+++ b/pkg/R/main.R
@@ -138,7 +138,7 @@ valse = function(X, Y, procedure='LassoMLE', selecMod='DDSE', gamma=1, mini=10,
   mod = as.character(tableauRecap[indModSel,1])
   listMod = as.integer(unlist(strsplit(mod, "[.]")))
   if (plot){
-    print(plot_valse())
+    print(plot_valse(models_list[[listMod[1]]][[listMod[2]]],n))
   }
   models_list[[listMod[1]]][[listMod[2]]]
   
diff --git a/pkg/R/plot_valse.R b/pkg/R/plot_valse.R
index 05963c8..2c74554 100644
--- a/pkg/R/plot_valse.R
+++ b/pkg/R/plot_valse.R
@@ -2,18 +2,21 @@
 #'
 #' It is a function which plots relevant parameters
 #'
-#'
+#' @param model the model constructed by valse procedure
+#' @param n sample size
 #' @return several plots
 #'
 #' @examples TODO
 #'
 #' @export
 #'
-plot_valse = function(){
+plot_valse = function(model,n){
   require("gridExtra")
   require("ggplot2")
   require("reshape2")
+  require("cowplot")
   
+  K = length(model$pi)
   ## regression matrices
   gReg = list()
   for (r in 1:K){
@@ -60,8 +63,8 @@ plot_valse = function(){
     gam2[i, ] = c(gam[i, affec[i]], affec[i])
   }
   bp <- ggplot(data.frame(gam2), aes(x=X2, y=X1, color=X2, group = X2)) +
-    geom_boxplot() + theme(legend.position = "none")
-  print(bp + background_grid(major = "xy", minor = "none"))
+    geom_boxplot() + theme(legend.position = "none")+ background_grid(major = "xy", minor = "none")
+  print(bp )
   
   ### Mean in each cluster
   XY = cbind(X,Y)
-- 
2.44.0