Skip to content

Commit 94e1eaf

Browse files
committed
jjstatsplot functions working with defaluts
1 parent f20ac2a commit 94e1eaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+928
-1998
lines changed

.Rprofile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,46 @@
11
options(repos = c("https://cran.microsoft.com/snapshot/2020-05-01"))
2+
# source("renv/activate.R")
3+
4+
# 'https://repo.jamovi.org'
5+
6+
# "/Users/serdarbalciold/Library/R/3.6/library"
7+
# "/Library/Frameworks/R.framework/Versions/3.6/Resources/library"
8+
9+
.libPaths(new = "~/histopathRprojects/ClinicoPathLibrary")
10+
11+
# source(
12+
# "renv/activate.R"
13+
# "~/histopathRprojects/ClinicoPath/renv/activate.R"
14+
# # here::here("renv/activate.R")
15+
# )
16+
17+
18+
# https://stackoverflow.com/questions/2096473/r-determine-if-a-script-is-running-in-windows-or-linux
19+
20+
# https://conjugateprior.org/2015/06/identifying-the-os-from-r/
21+
22+
23+
# if (.Platform$OS.type == "windows") {
24+
#
25+
# if (!requireNamespace('jmvtools')) install.packages('jmvtools', repos=c('https://repo.jamovi.org', 'https://cran.r-project.org'))
26+
#
27+
# library("jmvtools")
28+
#
29+
# jmvtools::check("C://Program Files//jamovi//bin")
30+
#
31+
# .libPaths(new = "C:\\ClinicoPathLibrary")
32+
#
33+
# Sys.setenv(TZ = "Europe/Istanbul")
34+
#
35+
# }
36+
37+
38+
.First <- function(){
39+
cat("\nWelcome to ClinicoPath", date(), "\n")
40+
}
41+
42+
43+
.Last <- function(){
44+
cat("\nGoodbye at ", date(), "\n")
45+
}
46+

DESCRIPTION

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Type: Package
22
Package: ClinicoPath
33
Title: Analysis for Clinicopathological Research
4-
Version: 0.0.2.0011
5-
Date: 2020-06-05
4+
Version: 0.0.2.0012
5+
Date: 2020-06-09
66
Authors@R:
77
person(given = "Serdar",
88
family = "Balci",
@@ -72,6 +72,11 @@ Suggests:
7272
gtsummary,
7373
vctrs,
7474
patchwork
75+
Remotes:
76+
ndphillips/FFTrees,
77+
easystats/report,
78+
spgarbet/tangram,
79+
cran/rmngb
7580
VignetteBuilder:
7681
knitr
7782
Encoding: UTF-8

R/jjbarstats.b.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jjbarstatsClass <- if (requireNamespace('jmvcore')) R6::R6Class(
2424
<br><br>
2525
This tool will help you generate Bar Charts.
2626
<br><br>
27-
This function uses ggplot2 and ggstatsplot packages. See documentations <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/ggbarstats.html' target='_blank'>here</a> and <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/grouped_ggbarstats.html' target='_blank'>here</a>.
27+
This function uses ggplot2 and ggstatsplot packages. See documentations <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/ggbarstats.html' target='_blank'>ggbarstats</a> and <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/grouped_ggbarstats.html' target='_blank'>grouped_ggbarstats</a>.
2828
<br>
2929
Please cite jamovi and the packages as given below.
3030
<br><hr>"

R/jjbetweenstats.b.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @title jjbetweenstats
1+
#' @title Violin Plots to Compare Between Groups
22
#'
33
#'
44
#'

R/jjbetweenstats.h.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ jjbetweenstatsOptions <- if (requireNamespace('jmvcore')) R6::R6Class(
2222
"dep",
2323
dep,
2424
suggested=list(
25-
"ordinal",
26-
"nominal"),
25+
"continuous"),
2726
permitted=list(
28-
"factor"))
27+
"numeric"))
2928
private$..group <- jmvcore::OptionVariable$new(
3029
"group",
3130
group,
@@ -191,7 +190,6 @@ jjbetweenstats <- function(
191190
`if`( ! missing(group), group, NULL),
192191
`if`( ! missing(grvar), grvar, NULL))
193192

194-
for (v in dep) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
195193
for (v in group) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
196194
for (v in grvar) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
197195

R/jjcorrmat.b.R

Lines changed: 86 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @title jjcorrmat
1+
#' @title Correlation Matrix
22
#'
33
#'
44
#' @importFrom R6 R6Class
@@ -14,16 +14,16 @@ jjcorrmatClass <- if (requireNamespace('jmvcore')) R6::R6Class(
1414
.run = function() {
1515

1616
# Initial Message ----
17-
if ( is.null(self$options$dep) ) {
17+
if ( length(self$options$dep) <= 1 ) {
1818

1919
# TODO ----
2020

2121
todo <- glue::glue(
22-
"<br>Welcome to ClinicoPath
22+
"<br>Welcome to ClinicoPath
2323
<br><br>
2424
This tool will help you generate Bar Charts.
2525
<br><br>
26-
This function uses ggplot2 and ggstatsplot packages. See documentations <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/ggbarstats.html' target='_blank'>here</a> and <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/grouped_ggbarstats.html' target='_blank'>here</a>.
26+
This function uses ggplot2 and ggstatsplot packages. See documentations <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/ggcorrmat.html' target='_blank'>ggcorrmat</a> and <a href = 'https://indrajeetpatil.github.io/ggstatsplot/reference/grouped_ggcorrmat.html' target='_blank'>grouped_ggcorrmat</a>.
2727
<br>
2828
Please cite jamovi and the packages as given below.
2929
<br><hr>"
@@ -54,7 +54,7 @@ jjcorrmatClass <- if (requireNamespace('jmvcore')) R6::R6Class(
5454
# the plot function ----
5555
# Error messages ----
5656

57-
if ( is.null(self$options$dep) )
57+
if ( length(self$options$dep) <= 1 )
5858
return()
5959

6060
if (nrow(self$data) == 0)
@@ -74,6 +74,7 @@ jjcorrmatClass <- if (requireNamespace('jmvcore')) R6::R6Class(
7474
if (excl) {mydata <- jmvcore::naOmit(mydata)}
7575

7676

77+
# define main arguments ----
7778

7879
myvars <- jmvcore::constructFormula(terms = self$options$dep)
7980

@@ -123,97 +124,90 @@ jjcorrmatClass <- if (requireNamespace('jmvcore')) R6::R6Class(
123124

124125
}
125126

126-
#
127-
# ,
128-
#
129-
# .plot2 = function(image, ...) {
130-
# # the plot function ----
131-
# # Error messages ----
132-
#
133-
# if ( is.null(self$options$dep) || is.null(self$options$grvar))
134-
# return()
135-
#
136-
# if (nrow(self$data) == 0)
137-
# stop('Data contains no (complete) rows')
138-
#
139-
#
140-
# # Prepare Data ----
141-
#
142-
# mydata <- self$data
143-
#
144-
#
145-
# # direction, paired ----
146-
#
147-
# direction <- self$options$direction
148-
#
149-
# if (direction == "repeated") {
150-
#
151-
# paired <- TRUE
152-
#
153-
# } else if (direction == "independent") {
154-
#
155-
# paired <- FALSE
156-
#
157-
# }
158-
#
159-
# # Exclude NA ----
160-
#
161-
# excl <- self$options$excl
162-
#
163-
# if (excl) {mydata <- jmvcore::naOmit(mydata)}
164-
#
165-
#
166-
#
167-
# dep <- self$options$dep
168-
#
169-
#
170-
#
171-
# dep <- jmvcore::composeTerm(components = dep)
172-
#
173-
#
174-
#
175-
#
176-
#
177-
#
178-
# # grouped_ggcorrmat
179-
# # https://indrajeetpatil.github.io/ggstatsplot/reference/grouped_ggcorrmat.html
180-
#
181-
#
182-
#
183-
# if ( !is.null(self$options$grvar) ) {
184-
# grvar <- self$options$grvar
185-
#
186-
# plot2 <- ggstatsplot::grouped_ggcorrmat(
187-
# data,
188-
# cor.vars = NULL,
189-
# cor.vars.names = NULL,
190-
# grouping.var,
191-
# title.prefix = NULL,
192-
# output = "plot",
193-
# ...,
194-
# plotgrid.args = list(),
195-
# title.text = NULL,
196-
# title.args = list(size = 16, fontface = "bold"),
197-
# caption.text = NULL,
198-
# caption.args = list(size = 10),
199-
# sub.text = NULL,
200-
# sub.args = list(size = 12)
201-
# )
202-
#
203-
#
204-
# }
205-
#
206-
# # Print Plot ----
207-
#
208-
# print(plot2)
209-
# TRUE
210-
#
211-
# }
212-
#
213127

128+
,
129+
130+
.plot2 = function(image, ...) {
131+
# the plot function ----
132+
# Error messages ----
133+
134+
if ( is.null(self$options$dep) || is.null(self$options$grvar))
135+
return()
136+
137+
if (nrow(self$data) == 0)
138+
stop('Data contains no (complete) rows')
139+
140+
141+
# Prepare Data ----
142+
143+
mydata <- self$data
144+
145+
146+
# direction, paired ----
147+
148+
direction <- self$options$direction
149+
150+
if (direction == "repeated") {
151+
152+
paired <- TRUE
153+
154+
} else if (direction == "independent") {
155+
156+
paired <- FALSE
157+
158+
}
159+
160+
# Exclude NA ----
161+
162+
excl <- self$options$excl
163+
164+
if (excl) {mydata <- jmvcore::naOmit(mydata)}
165+
166+
167+
# define main arguments ----
168+
169+
myvars <- jmvcore::constructFormula(terms = self$options$dep)
170+
171+
myvars <- jmvcore::decomposeFormula(formula = myvars)
172+
173+
myvars <- unlist(myvars)
174+
175+
176+
# grouped_ggcorrmat ----
177+
# https://indrajeetpatil.github.io/ggstatsplot/reference/grouped_ggcorrmat.html
214178

215179

216180

181+
if ( !is.null(self$options$grvar) ) {
182+
183+
grvar <- self$options$grvar
184+
185+
plot2 <- ggstatsplot::grouped_ggcorrmat(
186+
data = mydata,
187+
cor.vars = myvars,
188+
cor.vars.names = NULL,
189+
grouping.var = !!grvar,
190+
title.prefix = NULL,
191+
output = "plot",
192+
plotgrid.args = list(),
193+
title.text = NULL,
194+
title.args = list(size = 16, fontface = "bold"),
195+
caption.text = NULL,
196+
caption.args = list(size = 10),
197+
sub.text = NULL,
198+
sub.args = list(size = 12)
199+
)
200+
201+
202+
}
203+
204+
# Print Plot ----
205+
206+
print(plot2)
207+
TRUE
208+
209+
}
210+
217211
)
218212
)
219213

R/jjcorrmat.h.R

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ jjcorrmatResults <- if (requireNamespace('jmvcore')) R6::R6Class(
6565
inherit = jmvcore::Group,
6666
active = list(
6767
todo = function() private$.items[["todo"]],
68+
plot2 = function() private$.items[["plot2"]],
6869
plot = function() private$.items[["plot"]]),
6970
private = list(),
7071
public=list(
7172
initialize=function(options) {
7273
super$initialize(
7374
options=options,
7475
name="",
75-
title="jjcorrmat",
76+
title="Correlation Matrix",
7677
refs=list(
7778
"ggplot2",
7879
"ggstatsplot"))
@@ -84,10 +85,23 @@ jjcorrmatResults <- if (requireNamespace('jmvcore')) R6::R6Class(
8485
"dep",
8586
"grvar",
8687
"direction")))
88+
self$add(jmvcore::Image$new(
89+
options=options,
90+
name="plot2",
91+
title="Chart",
92+
width=800,
93+
height=600,
94+
renderFun=".plot2",
95+
requiresData=TRUE,
96+
clearWith=list(
97+
"dep",
98+
"grvar",
99+
"direction"),
100+
visible="(grvar)"))
87101
self$add(jmvcore::Image$new(
88102
options=options,
89103
name="plot",
90-
title="`Bar Chart ${group} - {dep}`",
104+
title="Chart",
91105
width=800,
92106
height=600,
93107
renderFun=".plot",
@@ -117,7 +131,7 @@ jjcorrmatBase <- if (requireNamespace('jmvcore')) R6::R6Class(
117131
requiresMissings = FALSE)
118132
}))
119133

120-
#' jjcorrmat
134+
#' Correlation Matrix
121135
#'
122136
#' 'Wrapper Function for ggstatsplot::ggbarstats and
123137
#' ggstatsplot::grouped_ggbarstats to generate Bar Charts.'
@@ -135,6 +149,7 @@ jjcorrmatBase <- if (requireNamespace('jmvcore')) R6::R6Class(
135149
#' @return A results object containing:
136150
#' \tabular{llllll}{
137151
#' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
152+
#' \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
138153
#' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
139154
#' }
140155
#'

0 commit comments

Comments
 (0)