From 2b26dd9f90bd9feb9963e146e7863b6862a40683 Mon Sep 17 00:00:00 2001 From: bruno boutin Date: Thu, 11 Apr 2024 17:35:08 +0200 Subject: [PATCH] Fetch flexplot from Descriptives (#56) --- .gitignore | 57 ++++++++++++ DESCRIPTION | 5 +- NAMESPACE | 1 + R/flexplot.R | 4 +- R/flexplotWrapper.R | 66 +++++++++++++ inst/Description.qml | 1 + inst/qml/Flexplot.qml | 209 +----------------------------------------- 7 files changed, 133 insertions(+), 210 deletions(-) create mode 100644 .gitignore create mode 100644 R/flexplotWrapper.R diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3124d80 --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +# History files +.Rhistory +.Rapp.history + +# Session Data files +.RData + +# User-specific files +.Ruserdata + +# Example code in package build process +*-Ex.R + +# Output files from R CMD build +/*.tar.gz + +# Output files from R CMD check +/*.Rcheck/ + +# produced vignettes +vignettes/*.html +vignettes/*.pdf + +# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 +.httr-oauth + +# knitr and R markdown default cache directories +*_cache/ +/cache/ + +# Temporary files created by R markdown +*.utf8.md +*.knit.md + +# R Environment Variables +.Renviron + +# pkgdown site +docs/ + +# translation temp files +po/*~ + +# OSX files +*.DS_Store +Thumbs.db + +# JASP analysis +state + +# RStudio files +.Rproj.user/* +Rproj.user +.Rproj.user +/.Rprofile +/renv.lock +/renv diff --git a/DESCRIPTION b/DESCRIPTION index 5167e58..3209851 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,8 +8,9 @@ Website: github.com/dustinfife/flexplot Maintainer: Dustin Fife Description: Graphically explore the dependencies between variables License: GPL (>= 2) -Imports: flexplot, jaspBase, jaspGraphs +Imports: flexplot, jaspBase, jaspGraphs, jaspDescriptives Remotes: dustinfife/flexplot, jasp-stats/jaspGraphs, - jasp-stats/jaspBase + jasp-stats/jaspBase, + jasp-stats/jaspDescriptives diff --git a/NAMESPACE b/NAMESPACE index 587831f..4c24728 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,5 @@ export(flexplot) +export(flexplotInternal) export(linmod) export(mixedmod) export(glinmod) diff --git a/R/flexplot.R b/R/flexplot.R index fee3f8c..eb91828 100644 --- a/R/flexplot.R +++ b/R/flexplot.R @@ -1,3 +1,3 @@ -flexplot <- function(jaspResults, dataset, options) { +flexplotInternal <- function(jaspResults, dataset, options) { return(flexplot:::flexplot_jasp2(jaspResults, dataset, options)) -} \ No newline at end of file +} diff --git a/R/flexplotWrapper.R b/R/flexplotWrapper.R new file mode 100644 index 0000000..c6bb1c2 --- /dev/null +++ b/R/flexplotWrapper.R @@ -0,0 +1,66 @@ +# +# Copyright (C) 2013-2022 University of Amsterdam +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This is a generated file. Don't change it + +flexplot <- function( + data = NULL, + version = "0.18.3", + formula = NULL, + alpha = 0.4, + bw = FALSE, + confidence = FALSE, + dependent = "", + ghost = TRUE, + intervals = "Quartiles", + jitx = 0.1, + jity = 0, + nameCols = "", + nameLegend = "", + nameRows = "", + nameX = "", + nameY = "", + palette = "GGplot Default", + paneledVars = list(), + plotHeight = 320, + plotWidth = 480, + theme = "JASP", + type = "Loess", + variables = list()) { + + defaultArgCalls <- formals(jaspVisualModeling::flexplot) + defaultArgs <- lapply(defaultArgCalls, eval) + options <- as.list(match.call())[-1L] + options <- lapply(options, eval) + defaults <- setdiff(names(defaultArgs), names(options)) + options[defaults] <- defaultArgs[defaults] + options[["data"]] <- NULL + options[["version"]] <- NULL + + if (!is.null(formula)) { + if (!inherits(formula, "formula")) { + formula <- as.formula(formula) + } + options$formula <- jaspBase::jaspFormula(formula, data) + } + + optionsWithFormula <- c("dependent", "intervals", "palette", "paneledVars", "theme", "type", "variables") + for (name in optionsWithFormula) { + if ((name %in% optionsWithFormula) && inherits(options[[name]], "formula")) options[[name]] = jaspBase::jaspFormula(options[[name]], data) } + + return(jaspBase::runWrappedAnalysis("jaspVisualModeling::flexplot", data, options, version)) +} diff --git a/inst/Description.qml b/inst/Description.qml index 41aa481..6cba9da 100755 --- a/inst/Description.qml +++ b/inst/Description.qml @@ -18,6 +18,7 @@ Description title: qsTr("Flexplot") qml: "Flexplot.qml" func: "flexplot" + hasWrapper: true } Analysis diff --git a/inst/qml/Flexplot.qml b/inst/qml/Flexplot.qml index 0ac51e0..fac4990 100755 --- a/inst/qml/Flexplot.qml +++ b/inst/qml/Flexplot.qml @@ -1,207 +1,4 @@ -import QtQuick 2.12 -import JASP.Controls 1.0 -import JASP.Widgets 1.0 -import JASP 1.0 +import QtQuick +import jaspDescriptives -Form -{ - - - VariablesForm - { - AvailableVariablesList { name: "allVariables" } - AssignedVariablesList { - name: "dependent" ; - title: qsTr("Dependent Variable") ; - singleVariable: true - onCountChanged: nameY.value = count > 0 ? model.data(model.index(0,0)) : "" - } - AssignedVariablesList { - name: "variables" ; - title: qsTr("Independent Variable(s)") ; - id: varlist - onCountChanged: { - nameLegend.value = count > 1 ? model.data(model.index(1,0)) : ""; - nameX.value = count > 0 ? model.data(model.index(0,0)) : ""; - } - - } - AssignedVariablesList { - name: "paneledVars" ; - title: qsTr("Paneled Variable(s)"); - id: paneledVars - onCountChanged: { - nameCols.value = count > 0 ? model.data(model.index(0,0)) : ""; - nameRows.value = count > 1 ? model.data(model.index(1,0)) : ""; - } - - } - } - - Section - { - title: qsTr("Options") - - Group - { - title: qsTr("
Point controls
") - columns: 4 - Slider - { - name: "alpha" - label: qsTr("Point transparency") - value: 0.4 - vertical: true - enabled: varlist.count > 0 - } - Slider - { - name: "jitx" - label: qsTr("Jitter in X") - value: .1 - min: 0 - max: .5 - vertical: true - enabled: varlist.count > 0 - } - Slider - { - name: "jity" - label: qsTr("Jitter in Y") - value: 0 - min: 0 - max: .5 - vertical: true - enabled: varlist.count > 0 - } - } - Group - { - Group - { - title: qsTr("Visual Statistics") - CheckBox - { - name:"confidence"; - label: qsTr("Plot confidence bands") - enabled: varlist.count > 0 - } - DropDown - { - name: "type" - values: - [ - {label: qsTr("Loess"), value: "Loess"}, - {label: qsTr("Regression"), value: "Regression"}, - {label: qsTr("Quadratic"), value: "Quadratic"}, - {label: qsTr("Cubic"), value: "Cubic"}, - {label: qsTr("None"), value: "None"} - ] - label: qsTr("Fitted line (scatterplots)") - enabled: varlist.count > 0 - } - DropDown - { - name: "intervals" - values: - [ - {label: qsTr("Quartiles"), value: "Quartiles"}, - {label: qsTr("Standard errors"), value: "Standard errors"}, - {label: qsTr("Standard deviations"), value: "Standard deviations"} - ] - label: qsTr("Intervals (categorical predictors)") - enabled: varlist.count > 0 - } - } - - Group - { - title: qsTr("
Other Plot Controls") - DropDown - { - name: "theme" - values: - [ - {label: qsTr("JASP"), value: "JASP"}, - {label: qsTr("Black and white"), value: "Black and white"}, - {label: qsTr("Minimal"), value: "Minimal"}, - {label: qsTr("Classic"), value: "Classic"}, - {label: qsTr("Dark"), value: "Dark"} - ] - label: qsTr("GGplot theme") - } - DropDown - { - name: "palette" - values: - [ - {label: qsTr("GGplot Default"), value: "GGplot Default"}, - {label: qsTr("Nature"), value: "Nature"}, - {label: qsTr("AAAS"), value: "AAAS"}, - {label: qsTr("Lancet"), value: "Lancet"}, - {label: qsTr("JCO"), value: "JCO"}, - {label: qsTr("Dark"), value: "Dark"} - ] - label: qsTr("Color Palette") - } - CheckBox - { - name:"bw"; - label: qsTr("Convert to grayscale"); - checked: false - } - - CheckBox - { - name:"ghost"; - label: qsTr("Ghost lines"); - checked: true - enabled: paneledVars.count > 0 - } - } - } - } - - Section - { - title: qsTr("Plot Labels") - Group - { - title: qsTr("
Plot Labels") - TextField - { - id: nameX; - label: qsTr("X Axis Label"); - name: "nameX"; - } - TextField - { - id: nameY - label: qsTr("Y Axis Label") - name: "nameY"; - value: xAxis.value - } - TextField - { - id: nameLegend - label: qsTr("Legend Label") - name: "nameLegend"; - value: legend.value - } - TextField - { - id: nameCols - label: qsTr("Column Panel Label") - name: "nameCols"; - value: cols.value - } - TextField - { - id: nameRows - label: qsTr("Row Panel Label") - name: "nameRows"; - value: rows.value - } - } - } -} +FlexplotForm {}