Skip to content

Commit

Permalink
guess_max parameter
Browse files Browse the repository at this point in the history
ref #194
  • Loading branch information
wibeasley committed May 25, 2018
1 parent 0947578 commit 32a0181
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions R/redcap-read-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#' @param export_data_access_groups A boolean value that specifies whether or not to export the `redcap_data_access_group` field when data access groups are utilized in the project. Default is `FALSE`. See the details below.
#' @param raw_or_label A string (either `'raw'` or `'label'`) that specifies whether to export the raw coded values or the labels for the options of multiple choice fields. Default is `'raw'`.
#' @param guess_type A boolean value indicating if all columns should be returned as character. If false, [readr::read_csv()] guesses the intended data type for each column.
#' @param guess_max A positive integer passed to [readr::read_csv()] that specifies the maximum number of records to use for guessing column types.
#' @param verbose A boolean value indicating if `message`s should be printed to the R console during the operation. The verbose output might contain sensitive information (*e.g.* PHI), so turn this off if the output might be visible somewhere public. Optional.
#' @param config_options A list of options to pass to `POST` method in the `httr` package. See the details below. Optional.
#' @return Currently, a list is returned with the following elements,
Expand Down Expand Up @@ -74,7 +75,8 @@ redcap_read_oneshot <- function(
export_data_access_groups=FALSE,
filter_logic="",
raw_or_label='raw',
guess_type = TRUE,
guess_type = TRUE,
guess_max = 1000L,
verbose=TRUE, config_options=NULL
) {
#TODO: NULL verbose parameter pulls from getOption("verbose")
Expand All @@ -86,6 +88,7 @@ redcap_read_oneshot <- function(
checkmate::assert_character(filter_logic , any.missing=F, len=1, pattern="^.{0,}$")
checkmate::assert_subset( raw_or_label , c("raw", "label"))
checkmate::assert_logical( guess_type , any.missing=F, len=1)
checkmate::assert_integer( guess_max , any.missing=F, len=1, lower=1)

token <- sanitize_token(token)
validate_field_names(fields)
Expand Down Expand Up @@ -152,7 +155,7 @@ redcap_read_oneshot <- function(
try (
{
# ds <- utils::read.csv(text=raw_text, stringsAsFactors=FALSE)
ds <- readr::read_csv(file=raw_text, col_types=col_types) %>%
ds <- readr::read_csv(file=raw_text, col_types=col_types, guess_max=guess_max) %>%
as.data.frame()
}, #Convert the raw text to a dataset.
silent = TRUE #Don't print the warning in the try block. Print it below, where it's under the control of the caller.
Expand Down
6 changes: 4 additions & 2 deletions man/redcap_read_oneshot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32a0181

Please sign in to comment.