Skip to content

Commit

Permalink
Merge pull request #34 from rcalinjageman/development
Browse files Browse the repository at this point in the history
estimate_r and estimate_rdiff_two - tests and documention, Changed all class functions to is functions, changes for statpsych 1.5
  • Loading branch information
rcalinjageman authored Feb 23, 2024
2 parents 42e8e9d + 87e7955 commit 4086e43
Show file tree
Hide file tree
Showing 66 changed files with 1,832 additions and 651 deletions.
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export(CI_diamond_ratio)
export(CI_smd_ind_contrast)
export(CI_smd_one)
export(esci_plot_difference_axis_x)
export(estimate_correlation)
export(estimate_magnitude)
export(estimate_mdiff_2x2_between)
export(estimate_mdiff_2x2_mixed)
Expand All @@ -18,6 +17,7 @@ export(estimate_pdiff_one)
export(estimate_pdiff_paired)
export(estimate_pdiff_two)
export(estimate_proportion)
export(estimate_r)
export(estimate_rdiff_two)
export(geom_meta_diamond_h)
export(jamovicorrelation)
Expand Down Expand Up @@ -56,6 +56,7 @@ export(plot_meta)
export(plot_pdiff)
export(plot_proportion)
export(plot_rdiff)
export(plot_scatter)
export(test_correlation)
export(test_mdiff)
export(test_pdiff)
Expand Down Expand Up @@ -98,4 +99,5 @@ importFrom(stats,quantile)
importFrom(stats,rnorm)
importFrom(stats,sd)
importFrom(utils,head)
importFrom(utils,packageVersion)
importFrom(utils,tail)
8 changes: 4 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# esci (0.01)
esci version 0.99 (Release data: March 2024)
===========

## Information
Changes:

- Alpha release; expect breaking changes still to come, especially with
* Alpha release; expect breaking changes still to come, especially with
graphing functions.
- Released to jamovi is 1.01
2 changes: 1 addition & 1 deletion R/class_estimate.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ esci_estimate_consolidate <- function(estimate_list) {
# Cycle through the list
for (estimate in estimate_list) {
# Check if the current list item is an estimate
if (class(estimate) == "esci_estimate") {
if (is(estimate, "esci_estimate")) {

# Handle warnings, consolidating with outcome variable name
if(length(estimate$warnings) > 0 ) {
Expand Down
2 changes: 2 additions & 0 deletions R/esci-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#' @importFrom stats sd
#' @importFrom utils head
#' @importFrom utils tail
#' @importFrom utils packageVersion
#' @importFrom grid grobName
#' @import ggplot2
#' @import ggdist
Expand All @@ -54,4 +55,5 @@ esci_solve_imports <- function() {
Rdpack::get_usage
mathjaxr::preview_rd
R6::is.R6
utils::packageVersion
}
8 changes: 4 additions & 4 deletions R/estimate_magnitude.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ estimate_magnitude <- function(
# We check to see if we have a tidy column name by trying to evaluate it
is_column_name <- try(outcome_variable, silent = TRUE)

if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
# Column names have been passed, check if need to be quoted up

outcome_variable_enquo <- rlang::enquo(outcome_variable)
outcome_variable_quoname <- try(
eval(rlang::as_name(outcome_variable_enquo)), silent = TRUE
)
if (class(outcome_variable_quoname) != "try-error") {
if (!is(outcome_variable_quoname, "try-error")) {
# This only succeeds if outcome_variable was passed unquoted
# Reset outcome_variable to be fully quoted
outcome_variable <- outcome_variable_quoname
Expand All @@ -178,12 +178,12 @@ estimate_magnitude <- function(
# Ready to be analyzed as a list of string column names
analysis_type <- "data.frame"

} else if (class(outcome_variable) == "numeric") {
} else if (is(outcome_variable, "numeric")) {
# At this stage, we know that y was not a tidy column name,
# so it should be either a vector of raw data (class = numeric)
# or a vector of column names passed as strings
analysis_type <- "vector"
} else if (class(outcome_variable) == "character") {
} else if (is(outcome_variable, "character")) {
# Ok, must have been string column names
if (length(outcome_variable) == 1) {
analysis_type <- "data.frame"
Expand Down
20 changes: 10 additions & 10 deletions R/estimate_mdiff_2x2_between.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ estimate_mdiff_2x2_between <- function(
# Check grouping_variable -- if it is an unquoted column name
# turn it into a string and store back to grouping_variable
is_column_name <- try(grouping_variable_A, silent = TRUE)
if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
grouping_variable_A_enquo <- rlang::enquo(grouping_variable_A)
grouping_variable_A_enquo_name <- try(
eval(rlang::as_name(grouping_variable_A_enquo)), silent = TRUE
)
if (class(grouping_variable_A_enquo_name) != "try-error") {
if (!is(grouping_variable_A_enquo_name, "try-error")) {
# This only succeeds if the columns were passed unquoted
# So now replace grouping_variable with a quoted version
grouping_variable_A <- grouping_variable_A_enquo_name
Expand All @@ -228,12 +228,12 @@ estimate_mdiff_2x2_between <- function(


is_column_name <- try(grouping_variable_B, silent = TRUE)
if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
grouping_variable_B_enquo <- rlang::enquo(grouping_variable_B)
grouping_variable_B_enquo_name <- try(
eval(rlang::as_name(grouping_variable_B_enquo)), silent = TRUE
)
if (class(grouping_variable_B_enquo_name) != "try-error") {
if (!is(grouping_variable_B_enquo_name, "try-error")) {
# This only succeeds if the columns were passed unquoted
# So now replace grouping_variable with a quoted version
grouping_variable_B <- grouping_variable_B_enquo_name
Expand All @@ -244,13 +244,13 @@ estimate_mdiff_2x2_between <- function(
# could be tidy column names, string column names, or vectors
# We check to see if we have a tidy column name by trying to evaluate it
is_column_name <- try(outcome_variable, silent = TRUE)
if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
# Column names have been passed, check if need to be quoted up
outcome_variable_enquo <- rlang::enquo(outcome_variable)
outcome_variable_quoname <- try(
eval(rlang::as_name(outcome_variable_enquo)), silent = TRUE
)
if (class(outcome_variable_quoname) != "try-error") {
if (!is(outcome_variable_quoname, "try-error")) {
# This only succeeds if outcome_variable was passed unquoted
# Reset outcome_variable to be fully quoted
outcome_variable <- outcome_variable_quoname
Expand All @@ -259,12 +259,12 @@ estimate_mdiff_2x2_between <- function(
# Ready to be analyzed as a list of string column names
analysis_type <- "data.frame"

} else if (class(outcome_variable) == "numeric") {
} else if (is(outcome_variable, "numeric")) {
# At this stage, we know that y was not a tidy column name,
# so it should be either a vector of raw data (class = numeric)
# or a vector of column names passed as strings
analysis_type <- "vector"
} else if (class(outcome_variable) == "character") {
} else if (is(outcome_variable, "character")) {
# Ok, must have been string column names
if (length(outcome_variable) == 1) {
analysis_type <- "data.frame"
Expand Down Expand Up @@ -831,7 +831,7 @@ estimate_mdiff_2x2_between.summary <- function(
)

for (x in 1:length(estimate)) {
if (class(estimate[[x]]) == "esci_estimate") {
if (is(estimate[[x]], "esci_estimate")) {
estimate[[x]]$overview <- overview
estimate[[x]]$properties$data_type <- "summary"
estimate[[x]]$properties$data_source <- NULL
Expand Down Expand Up @@ -1138,7 +1138,7 @@ estimate_mdiff_2x2_between.data.frame <- function(


for (x in 1:length(estimate)) {
if (class(estimate[[x]]) == "esci_estimate") {
if (is(estimate[[x]], "esci_estimate")) {
estimate[[x]]$overview <- overview
estimate[[x]]$raw_data <- if (save_raw_data) raw_data else NULL
estimate[[x]]$properties$data_type <- "data.frame"
Expand Down
8 changes: 4 additions & 4 deletions R/estimate_mdiff_2x2_mixed.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ estimate_mdiff_2x2_mixed <- function(
outcome_variable_level1_enquo_name <- try(
eval(rlang::as_name(outcome_variable_level1_enquo)), silent = TRUE
)
if (class(outcome_variable_level1_enquo_name) != "try-error") {
if (!is(outcome_variable_level1_enquo_name, "try-error")) {
# This only succeeds if the columns were passed unquoted
# So now replace outcome_variable_level1 with a quoted version
outcome_variable_level1 <- outcome_variable_level1_enquo_name
Expand All @@ -160,7 +160,7 @@ estimate_mdiff_2x2_mixed <- function(
outcome_variable_level2_enquo_name <- try(
eval(rlang::as_name(outcome_variable_level2_enquo)), silent = TRUE
)
if (class(outcome_variable_level2_enquo_name) != "try-error") {
if (!is(outcome_variable_level2_enquo_name, "try-error")) {
# This only succeeds if the columns were passed unquoted
# So now replace outcome_variable_level2 with a quoted version
outcome_variable_level2 <- outcome_variable_level2_enquo_name
Expand All @@ -170,7 +170,7 @@ estimate_mdiff_2x2_mixed <- function(
grouping_variable_enquo_name <- try(
eval(rlang::as_name(grouping_variable_enquo)), silent = TRUE
)
if (class(grouping_variable_enquo_name) != "try-error") {
if (!is(grouping_variable_enquo_name, "try-error")) {
# This only succeeds if the columns were passed unquoted
# So now replace grouping_variable with a quoted version
grouping_variable <- grouping_variable_enquo_name
Expand Down Expand Up @@ -428,7 +428,7 @@ estimate_mdiff_2x2_mixed <- function(
overview$outcome_variable_name <- outcome_variable_name

for (x in 1:length(estimate)) {
if (class(estimate[[x]]) == "esci_estimate") {
if (is(estimate[[x]], "esci_estimate")) {
estimate[[x]]$overview <- overview
estimate[[x]]$raw_data <- if (save_raw_data) raw_data else NULL
estimate[[x]]$properties$data_type <- "data.frame"
Expand Down
12 changes: 6 additions & 6 deletions R/estimate_mdiff_ind_contrast.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ estimate_mdiff_ind_contrast <- function(
# Check grouping_variable -- if it is an unquoted column name
# turn it into a string and store back to grouping_variable
is_column_name <- try(grouping_variable, silent = TRUE)
if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
grouping_variable_enquo <- rlang::enquo(grouping_variable)
grouping_variable_enquo_name <- try(
eval(rlang::as_name(grouping_variable_enquo)), silent = TRUE
)
if (class(grouping_variable_enquo_name) != "try-error") {
if (!is(grouping_variable_enquo_name, "try-error")) {
# This only succeeds if the columns were passed unquoted
# So now replace grouping_variable with a quoted version
grouping_variable <- grouping_variable_enquo_name
Expand All @@ -213,14 +213,14 @@ estimate_mdiff_ind_contrast <- function(
# We check to see if we have a tidy column name by trying to evaluate it
is_column_name <- try(outcome_variable, silent = TRUE)

if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
# Column names have been passed, check if need to be quoted up

outcome_variable_enquo <- rlang::enquo(outcome_variable)
outcome_variable_quoname <- try(
eval(rlang::as_name(outcome_variable_enquo)), silent = TRUE
)
if (class(outcome_variable_quoname) != "try-error") {
if (!is(outcome_variable_quoname, "try-error")) {
# This only succeeds if outcome_variable was passed unquoted
# Reset outcome_variable to be fully quoted
outcome_variable <- outcome_variable_quoname
Expand All @@ -229,12 +229,12 @@ estimate_mdiff_ind_contrast <- function(
# Ready to be analyzed as a list of string column names
analysis_type <- "data.frame"

} else if (class(outcome_variable) == "numeric") {
} else if (is(outcome_variable, "numeric")) {
# At this stage, we know that y was not a tidy column name,
# so it should be either a vector of raw data (class = numeric)
# or a vector of column names passed as strings
analysis_type <- "vector"
} else if (class(outcome_variable) == "character") {
} else if (is(outcome_variable, "character")) {
# Ok, must have been string column names
if (length(outcome_variable) == 1) {
analysis_type <- "data.frame"
Expand Down
8 changes: 4 additions & 4 deletions R/estimate_mdiff_one.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ estimate_mdiff_one <- function(
# We check to see if we have a tidy column name by trying to evaluate it
is_column_name <- try(outcome_variable, silent = TRUE)

if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
# Column names have been passed, check if need to be quoted up

outcome_variable_enquo <- rlang::enquo(outcome_variable)
outcome_variable_quoname <- try(
eval(rlang::as_name(outcome_variable_enquo)), silent = TRUE
)
if (class(outcome_variable_quoname) != "try-error") {
if (!is(outcome_variable_quoname, "try-error")) {
# This only succeeds if outcome_variable was passed unquoted
# Reset outcome_variable to be fully quoted
outcome_variable <- outcome_variable_quoname
Expand All @@ -227,12 +227,12 @@ estimate_mdiff_one <- function(
# Ready to be analyzed as a list of string column names
analysis_type <- "data.frame"

} else if (class(outcome_variable) == "numeric") {
} else if (is(outcome_variable, "numeric")) {
# At this stage, we know that y was not a tidy column name,
# so it should be either a vector of raw data (class = numeric)
# or a vector of column names passed as strings
analysis_type <- "vector"
} else if (class(outcome_variable) == "character") {
} else if (is(outcome_variable, "character")) {
# Ok, must have been string column names
if (length(outcome_variable) == 1) {
if (outcome_variable_name == "My outcome variable") {
Expand Down
12 changes: 6 additions & 6 deletions R/estimate_mdiff_paired.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ estimate_mdiff_paired <- function(
# Check reference_measure -- if it is an unquoted column name
# turn it into a string and store back to grouping_variable
is_column_name <- try(reference_measure, silent = TRUE)
if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
reference_measure_enquo <- rlang::enquo(reference_measure)
reference_measure_enquo_name <- try(
eval(rlang::as_name(reference_measure_enquo)), silent = TRUE
)
if (class(reference_measure_enquo_name) != "try-error") {
if (!is(reference_measure_enquo_name, "try-error")) {
# This only succeeds if the columns were passed unquoted
# So now replace grouping_variable with a quoted version
reference_measure <- reference_measure_enquo_name
Expand All @@ -263,26 +263,26 @@ estimate_mdiff_paired <- function(
# could be tidy column names, string column names, or vectors
# We check to see if we have a tidy column name by trying to evaluate it
is_column_name <- try(comparison_measure, silent = TRUE)
if(class(is_column_name) == "try-error") {
if(is(is_column_name, "try-error")) {
# Column names have been passed, check if need to be quoted up

comparison_measure_enquo <- rlang::enquo(comparison_measure)
comparison_measure_quoname <- try(
eval(rlang::as_name(comparison_measure_enquo)), silent = TRUE
)
if (class(comparison_measure_quoname) != "try-error") {
if (!is(comparison_measure_quoname, "try-error")) {
# This only succeeds if outcome_variable was passed unquoted
# Reset outcome_variable to be fully quoted
comparison_measure <- comparison_measure_quoname
}
analysis_type <- "data.frame"

} else if (class(comparison_measure) == "numeric") {
} else if (is(comparison_measure, "numeric")) {
# At this stage, we know that y was not a tidy column name,
# so it should be either a vector of raw data (class = numeric)
# or a vector of column names passed as strings
analysis_type <- "vector"
} else if (class(comparison_measure) == "character") {
} else if (is(comparison_measure, "character")) {
# Ok, must have been string column names
if (length(comparison_measure) == 1) {
analysis_type <- "data.frame"
Expand Down
8 changes: 4 additions & 4 deletions R/estimate_mdiff_two.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ estimate_mdiff_two <- function(
is_char <- try(
is.character(grouping_variable), silent = TRUE
)
if (class(is_char) == "try-error") {
if (is(is_char, "try-error")) {
# If not a character, must have been quoted
grouping_variable_enquo <- rlang::enquo(grouping_variable)
grouping_variable_quoname <- try(
eval(rlang::as_name(grouping_variable_enquo)), silent = TRUE
)
if (class(grouping_variable_quoname) != "try-error") {
if (!is(grouping_variable_quoname, "try-error")) {
# This only succeeds if outcome_variable was passed unquoted
# Reset outcome_variable to be fully quoted
grouping_variable <- grouping_variable_quoname
Expand All @@ -283,13 +283,13 @@ estimate_mdiff_two <- function(
is_char <- try(
is.character(outcome_variable), silent = TRUE
)
if (class(is_char) == "try-error") {
if (is(is_char, "try-error")) {
# If not a character, must have been quoted
outcome_variable_enquo <- rlang::enquo(outcome_variable)
outcome_variable_quoname <- try(
eval(rlang::as_name(outcome_variable_enquo)), silent = TRUE
)
if (class(outcome_variable_quoname) != "try-error") {
if (!is(outcome_variable_quoname, "try-error")) {
# This only succeeds if outcome_variable was passed unquoted
# Reset outcome_variable to be fully quoted
outcome_variable <- outcome_variable_quoname
Expand Down
Loading

0 comments on commit 4086e43

Please sign in to comment.