Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
12a741a
update version
jwildfire Feb 5, 2019
aa59ba6
add link between column and field in metadata. fix #113
jwildfire Feb 5, 2019
2776861
update description file
pburnsdata Feb 5, 2019
473b6d9
partial refactor of detectStandard(). #150
jwildfire Feb 5, 2019
42d4dfa
make measureValue settings required
jwildfire Feb 6, 2019
670c164
update manual
pburnsdata Feb 6, 2019
1cba9df
clarify code section of html report #149
pburnsdata Feb 6, 2019
714aa60
clean up
pburnsdata Feb 6, 2019
d20b76f
Update eDishReport.Rmd
jwildfire Feb 6, 2019
afb68e0
more detectStandard update/debug. #150
jwildfire Feb 6, 2019
403aa1c
Merge pull request #157 from ASA-DIA-InteractiveSafetyGraphics/export…
pburnsdata Feb 6, 2019
7e8f667
Merge pull request #156 from ASA-DIA-InteractiveSafetyGraphics/descri…
pburnsdata Feb 6, 2019
bee1c54
added test framework
jwildfire Feb 6, 2019
0c49776
started cleaning documentation #158
pburnsdata Feb 6, 2019
e7ee8ec
update other tests
jwildfire Feb 6, 2019
5f6a592
add includeFields. finish tests. fix #150
jwildfire Feb 6, 2019
731bf79
wrap up documentation updates
pburnsdata Feb 7, 2019
597fb46
merge dev branch. re-run docs.
jwildfire Feb 7, 2019
70b4b22
clean up docs. clear checks.
jwildfire Feb 7, 2019
d3c3c61
fix typo
jwildfire Feb 7, 2019
a0efb37
Merge pull request #161 from ASA-DIA-InteractiveSafetyGraphics/refact…
Feb 7, 2019
f085738
Merge branch 'dev-v0.8.0' into fix-doc-typos
Feb 7, 2019
67a1452
Merge pull request #160 from ASA-DIA-InteractiveSafetyGraphics/fix-do…
Feb 7, 2019
0f42647
initial commit for refactor
jwildfire Feb 7, 2019
3f6d826
update tests
jwildfire Feb 7, 2019
ccc6baa
updating tests
jwildfire Feb 8, 2019
57c35eb
integrate field data checks on data UI standard message
Feb 8, 2019
a10a128
a few more tests. remove requiredOnly option for now.
jwildfire Feb 8, 2019
a2592cd
tweak validation test to use required variable
jwildfire Feb 8, 2019
90ab6fc
all tests/checks passing. fix #135 #151
jwildfire Feb 8, 2019
6a0a412
Merge pull request #165 from ASA-DIA-InteractiveSafetyGraphics/refact…
Feb 8, 2019
b168a5b
modify for new generateSettings func
Feb 8, 2019
b366eb5
change to vertical layout
Feb 8, 2019
56e0d88
Merge pull request #169 from ASA-DIA-InteractiveSafetyGraphics/dev-v0…
Feb 8, 2019
aa9fbd9
refactor validateSettings and tests
jwildfire Feb 8, 2019
d6d9a9c
ignoring vectors for now. #170 filed.
jwildfire Feb 8, 2019
a3e3fdc
clear checks & fix #164
jwildfire Feb 9, 2019
6691d58
using . instead of .data$.
romainfrancois Feb 12, 2019
c798e6a
more validation tweaks. #172
jwildfire Feb 12, 2019
0b900ea
update per new detectStandard() output
Feb 12, 2019
f911f11
add info/details icons
Feb 12, 2019
a5967a3
move to single-column, collapsible layout
Feb 12, 2019
bdaf517
fix #172
jwildfire Feb 13, 2019
14313e8
update description
jwildfire Feb 13, 2019
676b123
Merge pull request #173 from romainfrancois/dplyr_0.8.0
Feb 13, 2019
9f40e7a
add package docs (and deal with .s). fix #175
jwildfire Feb 13, 2019
b8d43b0
remove settingsMetadata. fix #154
jwildfire Feb 13, 2019
f66a8a5
remove library calls
jwildfire Feb 13, 2019
5fff291
fixed space and removed from manual
pburnsdata Feb 13, 2019
30650fd
Merge pull request #176 from ASA-DIA-InteractiveSafetyGraphics/add-pa…
Feb 13, 2019
f79b94d
Merge branch 'dev-v0.8.0' into refactor-validation
Feb 13, 2019
aedab8d
Merge pull request #171 from ASA-DIA-InteractiveSafetyGraphics/refact…
Feb 13, 2019
1d44f25
Merge pull request #177 from ASA-DIA-InteractiveSafetyGraphics/drop-c…
Feb 13, 2019
6c07c4d
add tibble to description
jwildfire Feb 13, 2019
b70d1e5
Merge pull request #179 from ASA-DIA-InteractiveSafetyGraphics/dev-v0…
Feb 13, 2019
e342c7e
update per validateSettings update, fix #144
Feb 13, 2019
babe332
second fix for #144
Feb 15, 2019
41869d6
Merge pull request #181 from ASA-DIA-InteractiveSafetyGraphics/settin…
Feb 15, 2019
e5d65ad
add libs back into global.R only
Feb 15, 2019
27ad3c0
add call to lib in Rmarkdown
Feb 15, 2019
7f5cabb
Merge pull request #178 from ASA-DIA-InteractiveSafetyGraphics/no-lib…
Feb 15, 2019
28fe503
add lib call to report code
Feb 15, 2019
e0d43cd
Merge pull request #183 from ASA-DIA-InteractiveSafetyGraphics/add_li…
pburnsdata Feb 15, 2019
c738487
Drop rows and columns (#180)
pburnsdata Feb 15, 2019
70ea7a0
verified shinytests - updating expected
pburnsdata Feb 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: safetyGraphics
Title: Create Interactive Graphics Related to Clinical Trial Safety
Version: 0.7.3
Version: 0.8.0
Authors@R: c(
person("Jeremy", "Wildfire", email = "jeremy_wildfire@rhoworld.com", role = c("cre","aut")),
person("Becca", "Krouse", role="aut"),
Expand All @@ -11,6 +11,8 @@ Authors@R: c(
person("Rho Inc.", role = "cph"))
Maintainer: Jeremy Wildfire <jeremy_wildfire@rhoworld.com>
Description: A framework for evaluation of clinical trial safety. Users can interactively explore their data using the 'Shiny' application or create standalone 'htmlwidget' charts. Interactive charts are built using 'd3.js' and 'webcharts.js' 'JavaScript' libraries.
URL: https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics
BugReports: https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics/issues
Depends: R (>= 3.5)
License: MIT + file LICENSE
Encoding: UTF-8
Expand All @@ -21,16 +23,17 @@ Suggests:
shinytest,
knitr
Imports:
dplyr,
htmlwidgets,
purrr,
stringr,
jsonlite,
shiny,
magrittr,
DT,
shinyjs,
rmarkdown,
rlang
dplyr,
htmlwidgets,
purrr,
stringr,
jsonlite,
shiny,
magrittr,
DT,
shinyjs,
rmarkdown,
rlang,
tibble,
utils
VignetteBuilder: knitr

5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ import(htmlwidgets)
import(rmarkdown)
import(shinyjs)
importFrom(dplyr,"filter")
importFrom(dplyr,filter)
importFrom(magrittr,"%>%")
importFrom(purrr,keep)
importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_dbl)
importFrom(purrr,map_lgl)
importFrom(rlang,.data)
importFrom(rlang,parse_expr)
importFrom(shiny,runApp)
importFrom(stringr,str_detect)
importFrom(stringr,str_split)
importFrom(stringr,str_subset)
importFrom(tibble,tibble)
importFrom(utils,globalVariables)
19 changes: 10 additions & 9 deletions R/checkColumnSetting.R → R/checkColumn.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,37 @@
#' testSettings$filters[[3]]<-list(value_col="NotAColumn",label="Invalid Column")
#'
#' #pass ($valid == TRUE)
#' safetyGraphics:::checkColumnSetting(key=list("id_col"),
#' safetyGraphics:::checkColumn(key=list("id_col"),
#' settings=testSettings, adlbc)
#'
#' #pass
#' safetyGraphics:::checkColumnSetting(key=list("filters",1,"value_col"),
#' safetyGraphics:::checkColumn(key=list("filters",1,"value_col"),
#' settings=testSettings, adlbc)
#'
#' #NULL column pass
#' safetyGraphics:::checkColumnSetting(key=list("filters",2,"value_col"),
#' safetyGraphics:::checkColumn(key=list("filters",2,"value_col"),
#' settings=testSettings, adlbc)
#'
#' #invalid column fails
#' safetyGraphics:::checkColumnSetting(key=list("filters",3,"value_col"),
#' safetyGraphics:::checkColumn(key=list("filters",3,"value_col"),
#' settings=testSettings, adlbc)
#' @keywords internal

checkColumnSetting <- function(key, settings, data){
checkColumn <- function(key, settings, data){
stopifnot(typeof(key)=="list",typeof(settings)=="list")

validCols <- names(data)

current <- list(key=key)
current$text_key <- paste( unlist(current$key), collapse='--')
current$check <- "'_col' parameter from setting setting found in data?"
current$type <- "column"
current$description <- "column parameter from setting setting found in data?"
current$value <- getSettingValue(key=key,settings=settings)
if(is.null(current$value)){
current$value <- "--No Value Given--"
current$valid <- TRUE
current$message <- ""
return(current)
}else{
current$valid <- current$value %in% validCols
current$valid <- hasColumn(current$value, data)
current$message <- ifelse(current$valid,"",paste0(current$value," column not found in data."))
return(current)
}
Expand Down
45 changes: 45 additions & 0 deletions R/checkField.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#' Check that a setting parameter has a matching data field
#'
#' Checks that a single parameter from the settings list matches a field value in a specified data set
#'
#' This function compares settings with field values as part of the \code{validateSettings()} function. More specifically, the function checks whether the \code{fieldKey} in a \code{settings} object matches a column/field combination in \code{"data"}. The function makes 2 major assumptions about the structure of the settings object. First, it assumes that the first value in fieldKey is "settingName_values" and there is a corresponding "settingName_col" setting that defines the column to search for field-level data. Second, it expects that the value specified by key/settings is a list, and that each value in the list is a field of the variable above.
#'
#' @param fieldKey a list (like those provided by \code{getSettingKeys())} defining the position of parameter in the settings object.
#' @param settings The settings list used to generate a chart like \code{eDISH()}
#' @param data A data frame to check for the specified field
#' @return A list containing the results of the check following the format specified in \code{validateSettings()[["checkList"]]}
#'
#'
#' @examples
#' testSettings<-generateSettings(standard="AdAM")
#' fields<-list("measure_values","TB")
#' safetyGraphics:::checkFieldSettings(fieldKey=fields,settings=testSettings, data=adlbc)
#'
#' @keywords internal

checkFieldSettings <- function(fieldKey, settings, data){
stopifnot(typeof(fieldKey)=="list", typeof(settings)=="list")

# Check to see that the field data specified in the seetings is found in the data
fieldCheck <- list()
fieldCheck$key<-fieldKey
fieldCheck$text_key<- paste( unlist(fieldKey), collapse='--')
fieldCheck$type <- "field value from setting found in data"
fieldCheck$description <- "field value from setting found in data"
fieldCheck$value <- getSettingValue(key=fieldCheck$key,settings=settings)

#get the name of the column containing the field
columnTextKey<-getSettingsMetadata(cols="field_column_key",text_keys=fieldCheck$text_key)
columnKey<-textKeysToList(columnTextKey)[[1]]
columnName<-getSettingValue(key=columnKey,settings=settings)

if(length(fieldCheck$value)>0){
fieldCheck$valid <- hasField(fieldValue=fieldCheck$value, columnName=columnName,data=data)
}else{
fieldCheck$value <- "--No Value Given--"
fieldCheck$valid <- TRUE #null values are ok
}
fieldCheck$message <- ifelse(!fieldCheck$valid, paste0("Value of ",fieldCheck$value, " for '",fieldCheck$text_key,"' not found in ",columnName),"")

return(fieldCheck)
}
90 changes: 26 additions & 64 deletions R/checkFieldSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,75 +12,37 @@
#'
#' @examples
#' testSettings<-generateSettings(standard="AdAM")
#'
#' #list of 4 checks. all pass ($valid ==TRUE)
#' safetyGraphics:::checkFieldSettings(fieldKey=list("measure_values"),
#' settings=testSettings, adlbc)
#' fields<-list("measure_values","TB")
#' safetyGraphics:::checkField(fieldKey=fields,settings=testSettings, data=adlbc)
#'
#' @importFrom stringr str_split
#' @importFrom magrittr "%>%"
#' @importFrom purrr map
#'

checkFieldSettings <- function(fieldKey, settings, data){

# compare the fields in the settings to the fields in the data.
key <- NULL

fieldCheck <- function(key){
function(key){
current <- list()
current$key<-fieldKey
nextKey<-length(current$key)+1
current$key[[nextKey]]<-key

current$text_key <- paste( unlist(current$key), collapse='--')
current$check <- "'_values' field from setting found in data?"
current$value <- getSettingValue(key=current$key,settings=settings)
if(is.null(current$value)){
current$value <- "--No Value Given--"
current$valid <- TRUE
current$message <- ""
return(current)
}else if(!columnSpecified){
current$valid<-FALSE
current$message<-paste0("No column for ",columnKey," found in settings.")
}else{
current$valid <- current$value %in% validFields
current$message <- ifelse(current$valid,"",paste0(current$value," field not found in the ",columnName," column"))
return(current)
}
}
}

#' @keywords internal

checkField<- function(fieldKey, settings, data){
stopifnot(typeof(fieldKey)=="list", typeof(settings)=="list")

# get a list of all of the column's values from the data
key_base<-stringr::str_split(fieldKey, "_")[[1]][1] # get the name of the column containing the fields(e.g. fields = "measure_values" -> column = "measure_col")
columnKey<-getSettingKeys(patterns=paste0(key_base,"_col") ,settings=settings)[[1]]
columnName<-getSettingValue(key=columnKey, settings=settings) # get the name of the column from the value associated with columnKey
columnSpecified <- is.character(columnName)
if(columnSpecified){
validFields <- unique(data[[columnName]])
} else{
validFields <- c()
}

# get a list of fields from the settings object
fieldList<-getSettingValue(key=fieldKey, settings=settings)

if(typeof(fieldList)=="list"){
fieldChecks <- fieldList %>% names %>% purrr::map(fieldCheck(key))
} else {
current <- list()
current$key<-fieldKey
current$check <- "'_values' field from setting found in data?"
current$text_key <- paste( unlist(current$key), collapse='--')
current$value <- NULL
current$valid <- FALSE
current$message <- "No list of values found in settings."
fieldChecks <- list(current)

# Check to see that the field data specified in the seetings is found in the data
fieldCheck <- list()
fieldCheck$key<-fieldKey
fieldCheck$text_key<- paste( unlist(fieldKey), collapse='--')
fieldCheck$type <- "field"
fieldCheck$description <- "field value from setting found in data"
fieldCheck$value <- getSettingValue(key=fieldCheck$key,settings=settings)

#get the name of the column containing the field
columnTextKey<-getSettingsMetadata(cols="field_column_key",text_keys=fieldCheck$text_key)
columnKey<-textKeysToList(columnTextKey)[[1]]
columnName<-getSettingValue(key=columnKey,settings=settings)

if(length(fieldCheck$value)>0){
fieldCheck$valid <- hasField(fieldValue=fieldCheck$value, columnName=columnName,data=data)
}else{
fieldCheck$value <- "--No Value Given--"
fieldCheck$valid <- TRUE #null values are ok
}
return(fieldChecks)
fieldCheck$message <- ifelse(!fieldCheck$valid, paste0("Value of ",fieldCheck$value, " for '",fieldCheck$text_key,"' not found in ",columnName),"")

return(fieldCheck)
}
25 changes: 13 additions & 12 deletions R/checkNumericColumns.R → R/checkNumeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,30 @@
#'
#' @examples
#' testSettings<-generateSettings(standard="AdAM")
#' #pass ($valid == TRUE)
#' safetyGraphics:::checkSettingProvided(key=list("id_col"),settings=testSettings)
#' #pass ($valid == FALSE)
#' safetyGraphics:::checkNumeric(key=list("id_col"),settings=testSettings, data=adlbc)
#'
#' #fails since filters aren't specified by default
#' safetyGraphics:::checkSettingProvided(key=list("filters"),settings=testSettings)
#' #pass ($valid == TRUE)
#' safetyGraphics:::checkNumeric(key=list("value_col"),settings=testSettings, data=adlbc)
#'
#' #fails since groups aren't specified by default
#' safetyGraphics:::checkSettingProvided(key=list("groups",1,"value_col"),settings=testSettings)
#'
#' @keywords internal

checkNumericColumns <- function(key, settings, data){
checkNumeric <- function(key, settings, data){
stopifnot(typeof(key)=="list",typeof(settings)=="list")

current <- list(key=key)
current$text_key <- paste( unlist(current$key), collapse='--')
current$check <- "specified column is numeric?"
current$type <- "numeric"
current$description <- "specified column is numeric?"
current$value <- getSettingValue(key=key,settings=settings)
if(is.null(current$value)){
current$value <- "--No Value Given--"
current$valid <- TRUE
current$message <- ""
return(current)
}else if(!hasColumn(current$value,data)){
current$value <- "--Column not found--"
current$valid <- TRUE
current$message <- ""
}else{
#check to see if the specified column contains numeric values
values<- data[[current$value]]
Expand All @@ -42,7 +44,6 @@ checkNumericColumns <- function(key, settings, data){
current$valid <- percentNonNumeric < 0.5
current$message <- paste0(nonNumericCount," of ", totalCount," values were not numeric.")
if(nonNumericCount>0){current$message<-paste0(current$message, " Records with non-numeric values may not appear in the graphic.")}

return(current)
}
return(current)
}
13 changes: 7 additions & 6 deletions R/checkSettingProvided.R → R/checkRequired.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
#' testSettings<-generateSettings(standard="AdAM")
#'
#' #pass ($valid == TRUE)
#' safetyGraphics:::checkSettingProvided(key=list("id_col"),
#' safetyGraphics:::checkRequired(key=list("id_col"),
#' settings=testSettings)
#'
#' #fails since filters aren't specified by default
#' safetyGraphics:::checkSettingProvided(key=list("filters"),
#' safetyGraphics:::checkRequired(key=list("filters"),
#' settings=testSettings)
#'
#' #fails since groups aren't specified by default
#' safetyGraphics:::checkSettingProvided(key=list("groups",1,"value_col"),
#' safetyGraphics:::checkRequired(key=list("groups",1,"value_col"),
#' settings=testSettings)
#'
#' @keywords internal

checkSettingProvided <- function(key, settings){
checkRequired <- function(key, settings){
stopifnot(typeof(key)=="list",typeof(settings)=="list")

current <- list(key=key)
current$text_key <- paste( unlist(current$key), collapse='--')
current$check <- "value for specified key found in settings?"
current$type<-"required"
current$description <- "value for specified key found in settings?"
current$value <- getSettingValue(key=key,settings=settings)
if(is.null(current$value)){
current$value <- "--No Value Given--"
Expand Down
38 changes: 0 additions & 38 deletions R/compare_cols.R

This file was deleted.

Loading