Skip to content

Commit

Permalink
ggplot in r interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfanda committed Nov 19, 2018
1 parent d974a97 commit 84126f5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 45 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: gamlj
Type: Package
Title: GAMLj suite for jamovi
Version: 1.0.2
Version: 1.0.3
Author: Marcello Gallucci
Maintainer: Marcello Gallucci <mcfanda@gmail.com>
Description: A suite for estimation of linear model, such as the general linear model, linear mixed models,
generalized linear models. For ech family, models can be estimated
Description: A suite for estimation of linear models, such as the general linear model, linear mixed models,
and generalized linear models. For ech family, models can be estimated
with categorical and/or continuous variables, with options to facilitate estimation of
interactions, simple slopes, simple effects, post-hoc tests, contrast analysis and visualization of the results.
License: GPL
Expand Down
3 changes: 1 addition & 2 deletions R/gamljglm.b.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,7 @@ gamljGLMClass <- R6::R6Class(
} else {
p<-gplots.oneWayPlot(image,ggtheme,depName,groupName,errorType)
}
print(p)
TRUE
return(p)
},

.modelFormula=function() {
Expand Down
3 changes: 1 addition & 2 deletions R/gamljgzlm.b.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,7 @@ gamljGzlmClass <- R6::R6Class(
} else {
p<-gplots.linesMultiPlot(image,ggtheme,depName,groupName,linesName,plotsName,errorType)
}
print(p)
TRUE
return(p)
},

.fixedFormula=function() {
Expand Down
5 changes: 2 additions & 3 deletions R/gamljmixed.b.R
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ gamljMixedClass <- R6::R6Class(
rawData<-NULL
### this is specific of mixed model #####
cluster<-self$options$cluster[[1]]
preds<-c.real(cluster,groupName,linesName,plotsName)
preds<-c(cluster,groupName,linesName,plotsName)
preds64<-jmvcore::toB64(preds)

if (self$options$plotRandomEffects) {
Expand Down Expand Up @@ -554,8 +554,7 @@ gamljMixedClass <- R6::R6Class(
} else {
p<-gplots.oneWayPlot(image,ggtheme,depName,groupName,errorType)
}
print(p)
TRUE
return(p)
},

.fixedFormula=function() {
Expand Down
38 changes: 9 additions & 29 deletions R/rinterface.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,18 @@ gamlj_plot<-function(gobj,haxis,sepLines=NULL,sepPlots=NULL,...) {
#' This function returns the plot as a ggplot object

#' @param gobj a gamlj results object of the class GAMLj*#'
#' @param theme a theme for the ggplot plot. Default is the jamovi default theme
#' @param ... any other options accepted by the gamlj_* function
#' @return an object of class GAMLj* as the input object
#' @return an object of ggplot
#' @author Marcello Gallucci
#' @export

gamlj_ggplot<-function(gobj,...) {
options<-list(...)
if ("theme" %in% options)
theme<-options$theme
else
theme<-jmvcore::theme_default()

dep<-gobj$analysis$options$dep
haxis<-gobj$options$plotHAxis
sepLines<-gobj$options$plotSepLines
sepPlots<-gobj$options$plotSepPlots
errorType <- gobj$options$plotError
ciWidth <- gobj$options$ciWidth
image<-gobj$descPlot

if (errorType=="ci")
errorType<-paste0(ciWidth,"% ",toupper(errorType))

if ( ! is.null(sepLines)) {
p<-gplots.twoWaysPlot(image,theme,dep,sepLines,sepPlots,errorType)
} else {
p<-gplots.oneWayPlot(image,theme,dep,sepLines,errorType)
}
p

gamlj_ggplot<-function(gobj) {

if (length(gobj$descPlots)==0) {
gobj$descPlot$plot
} else {
gobj$descPlots
}

}

#' Update a GAMLj results by passing new simple effects directives
Expand Down Expand Up @@ -128,7 +109,6 @@ gamlj_simpleEffects<-function(gobj,variable=NULL,moderator=NULL,threeway=NULL,..
#' @author Marcello Gallucci
#' @export


gamlj_drop<-function(gobj,analysis) {
if (analysis=="simpleEffects") {
args<-list(simpleVariable=NULL,simpleModerator=NULL,simple3way=NULL)
Expand Down
8 changes: 2 additions & 6 deletions man/gamlj_ggplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 84126f5

Please sign in to comment.