Skip to content

Commit

Permalink
Checks #115 and disp example #116
Browse files Browse the repository at this point in the history
  • Loading branch information
dbosak01 committed Sep 4, 2023
1 parent 7231b88 commit a4a9466
Show file tree
Hide file tree
Showing 34 changed files with 1,778 additions and 42 deletions.
49 changes: 31 additions & 18 deletions R/proc_freq.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@
#' \item{\strong{crosstab}: Two-way output tables are a list style by default.
#' If you want a crosstab style, pass the "crosstab" option.
#' }
#' \item{\strong{fisher}: Requests that the Fisher's exact statistics be produced.
#' This option is only valid on two-way tables.
#' }
#' \item{\strong{list}: Two-way interactive tables are a crosstab style
#' by default. If you want a list style two-way table, pass the "list" option.
#' }
Expand Down Expand Up @@ -143,7 +140,17 @@
#' on output frequency tables. By default, these columns are not included.
#' The "outcum" option will include them.
#' }

#' }
#' @section Statistics Options:
#' In addition to the above options, the \code{options} parameter accepts
#' some statistics options. The following keywords will generate
#' an additional tables of specialized statistics. These statistics
#' options are only available on two-way tables:
#' \itemize{
#' \item{\strong{chisq}: Requests that the Chi-square statistics be produced.
#' }
#' \item{\strong{fisher}: Requests that the Fisher's exact statistics be produced.
#' }
#' }
#' @section Using Factors:
#' There are some occasions when you may want to define the \code{tables} variable
Expand Down Expand Up @@ -397,20 +404,6 @@ proc_freq <- function(data,
# plots = NULL
) {

kopts <- c("noprint",
"list", "nocol", "nocum", "nofreq", "nopercent",
"norow", "nosparse", "outcum",
"sparse", "crosstab",
"notable", "nonobs", "missing", "nlevels",
"wide", "long", "stacked") # vector not used

outopts <- c("out", "report", "none")

# "expected", "outexpect", "missprint"

vstats <- c("chisq", "cl", "fisher") # vector not used

nopts <- c("alpha", "maxlevels", "out") # vector not used

# Deal with single value unquoted parameter values
oby <- deparse(substitute(by, env = environment()))
Expand Down Expand Up @@ -473,6 +466,26 @@ proc_freq <- function(data,

}

if (!is.null(options)) {
kopts <- c("noprint",
"list", "nocol", "nocum", "nofreq", "nopercent",
"norow", "nosparse", "outcum",
"sparse", "crosstab",
"notable", "nonobs", "missing", "nlevels",
"chisq", "fisher", # Statistics options
"alpha" # Setting options
)

# Future options
# "expected", "outexpect", "missprint", "cl", "maxlevels"

if (!all(tolower(options) %in% kopts)) {

stop(paste("Invalid options keyword: ", options[!tolower(options) %in% kopts], "\n"))
}

}

# Set default statistics for output parameters
if (has_output(output))
outreq <- get_output_specs(tables, list(), options, output)
Expand Down
20 changes: 18 additions & 2 deletions R/proc_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
#' will be nested in the \code{by}.
# @param weight An optional weight parameter.
#' @param options A vector of optional keywords. Valid values are: "alpha =",
#' "completetypes", "long", "maxdec", "noprint", "notype, "nofreq", "nonobs".
#' "completetypes", "maxdec =", "noprint", "notype", "nofreq", "nonobs".
#' The "notype", "nofreq", and "nonobs" keywords will turn
#' off columns on the output datasets. The "alpha = " option will set the alpha
#' value for confidence limit statistics. The default is 95% (alpha = 0.05).
Expand Down Expand Up @@ -390,7 +390,7 @@ proc_means <- function(data,
if (!is.null(class)) {
if (!all(class %in% nms)) {

stop(paste("Invalid variable name: ", class[!class %in% nms], "\n"))
stop(paste("Invalid class name: ", class[!class %in% nms], "\n"))
}
}

Expand Down Expand Up @@ -419,6 +419,22 @@ proc_means <- function(data,

}

if (!is.null(options)) {
kopts <- c("alpha", "completetypes", "long", "maxdec",
"noprint", "notype", "nofreq", "nonobs")

# Deal with "alpha =" and "maxdec = " by using name instead of value
nopts <- names(options)
mopts <- ifelse(nopts == "", options, nopts)


if (!all(tolower(mopts) %in% kopts)) {

stop(paste("Invalid options keyword: ", mopts[!tolower(mopts) %in% kopts], "\n"))
}
}


# Generate output specs
if (has_output(output))
outreq <- get_output_specs_means(list(), stats, options, output)
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ articles:
- procs-dm
- procs-example1
- procs-example2
- procs-example3
- procs-faq

reference:
Expand Down
3 changes: 3 additions & 0 deletions docs/404.html

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

3 changes: 3 additions & 0 deletions docs/LICENSE.html

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

5 changes: 5 additions & 0 deletions docs/articles/index.html

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

3 changes: 3 additions & 0 deletions docs/articles/procs-dm.html

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

3 changes: 3 additions & 0 deletions docs/articles/procs-example1.html

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

3 changes: 3 additions & 0 deletions docs/articles/procs-example2.html

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

Loading

0 comments on commit a4a9466

Please sign in to comment.