Skip to content

Commit

Permalink
Attributes chart and type 1 study data loading
Browse files Browse the repository at this point in the history
  • Loading branch information
JTPetter committed Oct 11, 2024
1 parent d1b525c commit 3a4cb8e
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 41 deletions.
6 changes: 0 additions & 6 deletions R/attributesCharts.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ attributesCharts <- function(jaspResults, dataset, options) {
D <- options[["defectiveOrDefect"]]
timeStamp <- options$timeStamp

numeric_variables <- c(total, D)
numeric_variables <- numeric_variables[numeric_variables != ""]

# Data reading
if (is.null(dataset))
if (!identical(timeStamp, "")) {
dataset <- .readDataSetToEnd(columns.as.numeric = numeric_variables, columns.as.factor = timeStamp)
xLabs <- as.vector(dataset[, timeStamp])
} else {
dataset <- .readDataSetToEnd(columns.as.numeric = numeric_variables)
xLabs <- NULL
}

Expand Down
10 changes: 6 additions & 4 deletions R/doeAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ doeAnalysis <- function(jaspResults, dataset, options, ...) {
dependent <- options[["dependentResponseSurface"]]
}

dataset <- .doeAnalysisReadData(dataset, options, continuousPredictors, discretePredictors, blocks, covariates, dependent)
dataset <- na.omit(dataset)

if (length(blocks) > 0 && !identical(blocks, "")) # name of variable should always be "Block"
names(dataset)[names(dataset) == blocks] <- "Block"

if (length(blocks) > 0 && !identical(blocks, "")) # data reading function renames the block variable to "block"
if (length(blocks) > 0 && !identical(blocks, ""))
blocks <- "Block"

.doeAnalysisCheckErrors(dataset, options, continuousPredictors, discretePredictors, blocks, covariates, dependent, ready)
Expand Down Expand Up @@ -95,8 +98,7 @@ doeAnalysis <- function(jaspResults, dataset, options, ...) {
dataset <- .readDataSetToEnd(columns.as.numeric = numericVars, columns.as.factor = factorVars)
dataset <- na.omit(dataset)

if (length(blocks) > 0 && !identical(blocks, "")) # name of variable should always be "Block"
names(dataset)[names(dataset) == blocks] <- "Block"

return(dataset)
}

Expand Down
4 changes: 1 addition & 3 deletions R/msaType1Gauge.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ msaType1Gauge <- function(jaspResults, dataset, options, ...) {

ready <- (length(measurements) != 0)

if (is.null(dataset)) {
dataset <- .readDataSetToEnd(columns.as.numeric = measurements, exclude.na.listwise = measurements)
}
dataset <- jaspBase::excludeNaListwise(dataset, columns = measurements)

# Bias Run Chart
if (options[["runChart"]]) {
Expand Down
1 change: 1 addition & 0 deletions inst/Description.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Description
website: "https://github.com/jasp-stats/jaspQualityControl"
license: "GPL (>= 2)"
icon: "qualityControl-module.svg"
preloadData: true

GroupTitle
{
Expand Down
21 changes: 0 additions & 21 deletions tests/testthat/SPC_P.csv

This file was deleted.

File renamed without changes.
21 changes: 21 additions & 0 deletions tests/testthat/datasets/attributeCharts/SPC_P.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
,Month,Size,D,Proportion
1,Sep,150,21,0.14
2,Oct,153,16,0.105
3,Nov,170,30,0.176
4,Dec,226,31,0.137
5,Jan,154,24,0.156
6,Feb,130,33,0.254
7,Mar,190,32,0.168
8,Apr,165,29,0.176
9,May,176,23,0.131
10,Jun,144,17,0.118
11,Jul,132,14,0.106
12,Aug,144,31,0.215
13,Sep,156,29,0.186
14,Oct,158,25,0.158
15,Nov,142,15,0.106
16,Dec,212,43,0.203
17,Jan,155,20,0.129
18,Feb,138,26,0.188
19,Mar,141,23,0.163
20,Apr,130,28,0.215
15 changes: 8 additions & 7 deletions tests/testthat/test-attributesCharts.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ context("[Quality Control] Attributes Charts")
# NP
options <- analysisOptions("attributesCharts")
options$defectiveOrDefect <- "D"
options$defectiveOrDefect.types <- "scale"
options$total <- "Size"
options$attributesChart <- "defectives"
options$attributesChartDefectivesChartType <- "npChart"
set.seed(1)
results <- runAnalysis("attributesCharts", "SPC_NP.csv", options)
results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_NP.csv", options)

test_that("np Chart plot matches", {
plotName <- results[["results"]][["NPchartPlot"]][["data"]]
Expand All @@ -25,7 +26,7 @@ test_that("Test results for np chart table results match", {

# P
options$attributesChartDefectivesChartType <- "pChart"
results <- runAnalysis("attributesCharts", "SPC_P.csv", options)
results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options)

test_that("p Chart plot matches", {
plotName <- results[["results"]][["PchartPlot"]][["data"]]
Expand All @@ -35,7 +36,7 @@ test_that("p Chart plot matches", {

# Laney's P
options$attributesChartDefectivesChartType <- "laneyPPrimeChart"
results <- runAnalysis("attributesCharts", "SPC_P.csv", options)
results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options)

test_that("Laney p' Chart plot matches", {
plotName <- results[["results"]][["LaneyPPlot"]][["data"]]
Expand All @@ -48,7 +49,7 @@ test_that("Laney p' Chart plot matches", {
options$attributesChartDefectivesChartType <- "npChart"
options$attributesChart <- "defects"
options$attributesChartDefectsChartType <- "cChart"
results <- runAnalysis("attributesCharts", "SPC_NP.csv", options)
results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_NP.csv", options)

test_that("c Chart plot matches", {
plotName <- results[["results"]][["CchartPlot"]][["data"]]
Expand All @@ -64,7 +65,7 @@ test_that("Test results for c chart table results match", {

# U
options$attributesChartDefectsChartType <- "uChart"
results <- runAnalysis("attributesCharts", "SPC_P.csv", options)
results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options)

test_that("u Chart plot matches", {
plotName <- results[["results"]][["UchartPlot"]][["data"]]
Expand All @@ -74,7 +75,7 @@ test_that("u Chart plot matches", {

# Laneys U
options$attributesChartDefectsChartType <- "laneyUPrimeChart"
results <- runAnalysis("attributesCharts", "SPC_P.csv", options)
results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options)

test_that("Laney u' Chart plot matches", {
plotName <- results[["results"]][["LaneyUPlot"]][["data"]]
Expand All @@ -84,7 +85,7 @@ test_that("Laney u' Chart plot matches", {

## I MR
options$attributesChart <- "xmr"
results <- runAnalysis("attributesCharts", "SPC_P.csv", options)
results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options)

test_that("Individuals and Moving Range Chart plot matches", {
plotName <- results[["results"]][["IPlotA"]][["data"]]
Expand Down
Loading

0 comments on commit 3a4cb8e

Please sign in to comment.