Skip to content

Commit

Permalink
Process Capability R4.3.1 reshaping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JTPetter committed Oct 2, 2023
1 parent 42f1101 commit 1a29d0a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions R/processCapabilityStudies.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ processCapabilityStudies <- function(jaspResults, dataset, options) {
measurements <- colnames(dataset)
subgroups <- ""
}else{
k <- subgroups
dataset <- .PClongTowide(dataset, k, measurements, mode = "subgroups")
measurements <- colnames(dataset)
measurements <- measurements[measurements != k]
k <- dataset[[subgroups]]
k <- na.omit(k)
# add sequence of occurence to allow pivot_wider
occurenceVector <- with(dataset, ave(seq_along(k), k, FUN = seq_along))
dataset$occurence <- occurenceVector
# transform into one group per row
dataset <- tidyr::pivot_wider(data = dataset, values_from = tidyr::all_of(measurements), names_from = occurence)
# arrange into dataframe
dataset <- as.data.frame(dataset)
measurements <- as.character(unique(occurenceVector))
}
}

Expand Down

0 comments on commit 1a29d0a

Please sign in to comment.