Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 5 additions & 15 deletions R/freqplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,15 @@ freqplot <- function(type = "barchart", orient = "vertical", scale = "freq",

# Non-standard evaluation

otype <- deparse(substitute(type, env = environment()))
type <- tryCatch({if (typeof(type) %in% c("character", "NULL")) type else otype},
error = function(cond) {otype})
type <- resolve_arg(type)

oorient <- deparse(substitute(orient, env = environment()))
orient <- tryCatch({if (typeof(orient) %in% c("character", "NULL")) orient else oorient},
error = function(cond) {oorient})
orient <- resolve_arg(orient)

oscale <- deparse(substitute(scale, env = environment()))
scale <- tryCatch({if (typeof(scale) %in% c("character", "NULL")) scale else oscale},
error = function(cond) {oscale})
scale <- resolve_arg(scale)

otwoway <- deparse(substitute(twoway, env = environment()))
twoway <- tryCatch({if (typeof(twoway) %in% c("character", "NULL")) twoway else otwoway},
error = function(cond) {otwoway})
twoway <- resolve_arg(twoway)

ogroupby <- deparse(substitute(groupby, env = environment()))
groupby <- tryCatch({if (typeof(groupby) %in% c("character", "NULL")) groupby else ogroupby},
error = function(cond) {ogroupby})
groupby <- resolve_arg(groupby)

if (length(type) > 1) {
stop("Parmeter 'type' is invalid. Value must be a single character string.")
Expand Down
33 changes: 7 additions & 26 deletions R/proc_freq.R
Original file line number Diff line number Diff line change
Expand Up @@ -517,31 +517,12 @@ proc_freq <- function(data,
where = NULL
) {

# Deal with single value unquoted parameter values
oby <- deparse(substitute(by, env = environment()))
by <- tryCatch({if (typeof(by) %in% c("character", "NULL")) by else oby},
error = function(cond) {oby})

otables <- deparse(substitute(tables, env = environment()))
tables <- tryCatch({if (typeof(tables) %in% c("character", "NULL")) tables else otables},
error = function(cond) {otables})

owgt <- deparse(substitute(weight, env = environment()))
weight <- tryCatch({if (typeof(weight) %in% c("character", "NULL")) weight else owgt},
error = function(cond) {owgt})

oopt <- deparse(substitute(options, env = environment()))
options <- tryCatch({if (typeof(options) %in% c("character", "NULL")) options else oopt},
error = function(cond) {oopt})

oout <- deparse(substitute(output, env = environment()))
output <- tryCatch({if (typeof(output) %in% c("character", "NULL")) output else oout},
error = function(cond) {oout})

rout <- deparse(substitute(order, env = environment()))
order <- tryCatch({if (typeof(order) %in% c("character", "NULL")) order else rout},
error = function(cond) {rout})

by <- resolve_arg(by)
tables <- resolve_arg(tables)
weight <- resolve_arg(weight)
options <- resolve_arg(options)
output <- resolve_arg(output)
order <- resolve_arg(order)

# Parameter checks

Expand Down Expand Up @@ -649,7 +630,7 @@ proc_freq <- function(data,

# Deal with where expression
if (!is.null(where)) {
data <- subset(data, eval(where))
data <- subset_data(data, where)
}

rptflg <- FALSE
Expand Down
30 changes: 8 additions & 22 deletions R/proc_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,34 +366,20 @@ proc_means <- function(data,


# Deal with single value unquoted parameter values
oby <- deparse(substitute(by, env = environment()))
by <- tryCatch({if (typeof(by) %in% c("character", "NULL")) by else oby},
error = function(cond) {oby})
by <- resolve_arg(by)

# Deal with single value unquoted parameter values
oclass <- deparse(substitute(class, env = environment()))
class <- tryCatch({if (typeof(class) %in% c("character", "NULL")) class else oclass},
error = function(cond) {oclass})
class <- resolve_arg(class)

ovar <- deparse(substitute(var, env = environment()))
var <- tryCatch({if (typeof(var) %in% c("character", "NULL")) var else ovar},
error = function(cond) {ovar})
var <- resolve_arg(var)

oweight <- deparse(substitute(weight, env = environment()))
weight <- tryCatch({if (typeof(weight) %in% c("character", "NULL")) weight else oweight},
error = function(cond) {oweight})
weight <- resolve_arg(weight)

ostats <- deparse(substitute(stats, env = environment()))
stats <- tryCatch({if (typeof(stats) %in% c("character", "NULL")) stats else ostats},
error = function(cond) {ostats})
stats <- resolve_arg(stats)

oopt <- deparse(substitute(options, env = environment()))
options <- tryCatch({if (typeof(options) %in% c("integer", "double", "character", "NULL")) options else oopt},
error = function(cond) {oopt})
options <- resolve_arg(options, type = c("character", "double", "integer", "NULL"))

oout <- deparse(substitute(output, env = environment()))
output <- tryCatch({if (typeof(output) %in% c("character", "NULL")) output else oout},
error = function(cond) {oout})
output <- resolve_arg(output)

# Parameter checks

Expand Down Expand Up @@ -521,7 +507,7 @@ proc_means <- function(data,

# Deal with where expression
if (!is.null(where)) {
data <- subset(data, eval(where))
data <- subset_data(data, where)
}

# Get report if requested
Expand Down
22 changes: 6 additions & 16 deletions R/proc_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -443,26 +443,16 @@ proc_reg <- function(data,
missing <- FALSE

# Deal with single value unquoted parameter values
oweight <- deparse(substitute(weight, env = environment()))
weight <- tryCatch({if (typeof(weight) %in% c("character", "NULL")) weight else oweight},
error = function(cond) {oweight})
weight <- resolve_arg(weight)

# Deal with single value unquoted parameter values
oby <- deparse(substitute(by, env = environment()))
by <- tryCatch({if (typeof(by) %in% c("character", "NULL")) by else oby},
error = function(cond) {oby})
by <- resolve_arg(by)

ostats <- deparse(substitute(stats, env = environment()))
stats <- tryCatch({if (typeof(stats) %in% c("character", "NULL")) stats else ostats},
error = function(cond) {ostats})
stats <- resolve_arg(stats)

oopt <- deparse(substitute(options, env = environment()))
options <- tryCatch({if (typeof(options) %in% c("integer", "double", "character", "NULL")) options else oopt},
error = function(cond) {oopt})
options <- resolve_arg(options, type = c("integer", "double", "character", "NULL"))

oout <- deparse(substitute(output, env = environment()))
output <- tryCatch({if (typeof(output) %in% c("character", "NULL")) output else oout},
error = function(cond) {oout})
output <- resolve_arg(output)


# Parameter checks
Expand Down Expand Up @@ -596,7 +586,7 @@ proc_reg <- function(data,

# Where subset
if (!is.null(where)) {
data <- subset(data, eval(where))
data <- subset_data(data, where)
}

# Get report if requested
Expand Down
25 changes: 6 additions & 19 deletions R/proc_sort.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,40 +141,27 @@ proc_sort <- function(data, by = NULL, keep = NULL, order = "ascending",
options = NULL, as.character = FALSE, na.sort = NULL,
where = NULL) {


# Deal with single value unquoted parameter values
oby <- deparse(substitute(by, env = environment()))
by <- tryCatch({if (typeof(by) %in% c("character", "NULL")) by else oby},
error = function(cond) {oby})
by <- resolve_arg(by)

# Deal with single value unquoted parameter values
okeep <- deparse(substitute(keep, env = environment()))
keep <- tryCatch({if (typeof(keep) %in% c("character", "NULL")) keep else okeep},
error = function(cond) {okeep})

keep <- resolve_arg(keep)

# Deal with single value unquoted parameter values
oorder <- deparse(substitute(order, env = environment()))
order <- tryCatch({if (typeof(order) %in% c("character", "NULL")) order else oorder},
error = function(cond) {oorder})
order <- resolve_arg(order)

# Deal with single value unquoted option values
oopt <- deparse(substitute(options, env = environment()))
options <- tryCatch({if (typeof(options) %in% c("integer", "double", "character", "NULL")) options else oopt},
error = function(cond) {oopt})
options <- resolve_arg(options, type = c("character", "double", "integer", "NULL"))

# Deal with single value unquoted option values
onasort <- deparse(substitute(na.sort, env = environment()))
na.sort <- tryCatch({if (typeof(na.sort) %in% c("character", "NULL")) na.sort else onasort},
error = function(cond) {onasort})
na.sort <- resolve_arg(na.sort)

# Force to lower case
if (!is.null(na.sort)) {
na.sort <- tolower(na.sort)
}

# Parameter checks

if (!"data.frame" %in% class(data)) {
stop("Input data is not a data frame.")
}
Expand All @@ -185,7 +172,7 @@ proc_sort <- function(data, by = NULL, keep = NULL, order = "ascending",

# Deal with where expression
if (!is.null(where)) {
data <- subset(data, eval(where))
data <- subset_data(data, where)
}

if (!is.null(order)) {
Expand Down
47 changes: 12 additions & 35 deletions R/proc_transpose.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,53 +172,31 @@ proc_transpose <- function(data,
}

# Deal with single value unquoted parameter values
oby <- deparse(substitute(by, env = environment()))
by <- tryCatch({if (typeof(by) %in% c("character", "NULL")) by else oby},
error = function(cond) {oby})
by <- resolve_arg(by)

# Deal with single value unquoted parameter values
ovar <- deparse(substitute(var, env = environment()))
var <- tryCatch({if (typeof(var) %in% c("character", "NULL")) var else ovar},
error = function(cond) {ovar})
var <- resolve_arg(var)

# Deal with single value unquoted parameter values
oid <- deparse(substitute(id, env = environment()))
id <- tryCatch({if (typeof(id) %in% c("character", "NULL")) id else oid},
error = function(cond) {oid})
id <- resolve_arg(id)

# Deal with single value unquoted parameter values
oidlabel <- deparse(substitute(idlabel, env = environment()))
idlabel <- tryCatch({if (typeof(idlabel) %in% c("character", "NULL")) idlabel else oidlabel},
error = function(cond) {oidlabel})
idlabel <- resolve_arg(idlabel)

# Deal with single value unquoted parameter values
ocopy <- deparse(substitute(copy, env = environment()))
copy <- tryCatch({if (typeof(copy) %in% c("character", "NULL")) copy else ocopy},
error = function(cond) {ocopy})
copy <- resolve_arg(copy)

oname <- deparse(substitute(name, env = environment()))
name <- tryCatch({if (typeof(name) %in% c("character", "NULL")) name else oname},
error = function(cond) {oname})
name <- resolve_arg(name)

onamelabel <- deparse(substitute(namelabel, env = environment()))
namelabel <- tryCatch({if (typeof(namelabel) %in% c("character", "NULL")) namelabel else onamelabel},
error = function(cond) {onamelabel})
namelabel <- resolve_arg(namelabel)

oprefix <- deparse(substitute(prefix, env = environment()))
prefix <- tryCatch({if (typeof(prefix) %in% c("character", "NULL")) prefix else oprefix},
error = function(cond) {oprefix})
prefix <- resolve_arg(prefix)

osuffix <- deparse(substitute(suffix, env = environment()))
suffix <- tryCatch({if (typeof(suffix) %in% c("character", "NULL")) suffix else osuffix},
error = function(cond) {osuffix})
suffix <- resolve_arg(suffix)

odelimiter <- deparse(substitute(delimiter, env = environment()))
delimiter <- tryCatch({if (typeof(delimiter) %in% c("character", "NULL")) delimiter else odelimiter},
error = function(cond) {odelimiter})
delimiter <- resolve_arg(delimiter)

ooptions <- deparse(substitute(options, env = environment()))
options <- tryCatch({if (typeof(options) %in% c("character", "NULL")) options else ooptions},
error = function(cond) {ooptions})
options <- resolve_arg(options)

# Parameter checks

Expand Down Expand Up @@ -497,8 +475,7 @@ proc_transpose <- function(data,

# Where
if (!is.null(where)) {
res <- subset(res, eval(where))

res <- subset_data(res, where)
}

if ("noname" %in% options) {
Expand Down
30 changes: 8 additions & 22 deletions R/proc_ttest.R
Original file line number Diff line number Diff line change
Expand Up @@ -424,34 +424,20 @@ proc_ttest <- function(data,


# Deal with single value unquoted parameter values
oby <- deparse(substitute(by, env = environment()))
by <- tryCatch({if (typeof(by) %in% c("character", "NULL")) by else oby},
error = function(cond) {oby})
by <- resolve_arg(by)

# Deal with single value unquoted parameter values
oclass <- deparse(substitute(class, env = environment()))
class <- tryCatch({if (typeof(class) %in% c("character", "NULL")) class else oclass},
error = function(cond) {oclass})
class <- resolve_arg(class)

ovar <- deparse(substitute(var, env = environment()))
var <- tryCatch({if (typeof(var) %in% c("character", "NULL")) var else ovar},
error = function(cond) {ovar})
var <- resolve_arg(var)

oopt <- deparse(substitute(options, env = environment()))
options <- tryCatch({if (typeof(options) %in% c("integer", "double", "character", "NULL")) options else oopt},
error = function(cond) {oopt})
options <- resolve_arg(options, type = c("character", "double", "integer", "NULL"))

oout <- deparse(substitute(output, env = environment()))
output <- tryCatch({if (typeof(output) %in% c("character", "NULL")) output else oout},
error = function(cond) {oout})
output <- resolve_arg(output)

opaired <- deparse(substitute(paired, env = environment()))
paired <- tryCatch({if (typeof(paired) %in% c("character", "NULL")) paired else opaired},
error = function(cond) {opaired})
paired <- resolve_arg(paired)

rout <- deparse(substitute(order, env = environment()))
order <- tryCatch({if (typeof(order) %in% c("character", "NULL")) order else rout},
error = function(cond) {rout})
order <- resolve_arg(order)

# Parameter checks
if (!"data.frame" %in% class(data)) {
Expand Down Expand Up @@ -600,7 +586,7 @@ proc_ttest <- function(data,

# Where subset
if (!is.null(where)) {
data <- subset(data, eval(where))
data <- subset_data(data, where)
}

# Deal with order
Expand Down
12 changes: 3 additions & 9 deletions R/regplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,11 @@ regplot <- function(type = c("diagnostics", "residuals", "fitplot"), panel = TRU

# Non-standard evaluation

otype <- deparse(substitute(type, env = environment()))
type <- tryCatch({if (typeof(type) %in% c("character", "NULL")) type else otype},
error = function(cond) {otype})
type <- resolve_arg(type)

ostats <- deparse(substitute(stats, env = environment()))
stats <- tryCatch({if (typeof(stats) %in% c("character", "NULL")) stats else ostats},
error = function(cond) {ostats})
stats <- resolve_arg(stats)

oid <- deparse(substitute(id, env = environment()))
id <- tryCatch({if (typeof(id) %in% c("character", "NULL")) id else oid},
error = function(cond) {oid})
id <- resolve_arg(id)


# Parameter Checks
Expand Down
4 changes: 1 addition & 3 deletions R/ttestplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@
ttestplot <- function(type = "default", panel = TRUE, showh0 = FALSE, label = TRUE, id = NULL) {

# Non-standard evaluation
otype <- deparse(substitute(type, env = environment()))
type <- tryCatch({if (typeof(type) %in% c("character", "NULL")) type else otype},
error = function(cond) {otype})
type <- resolve_arg(type)


# agreement, boxplot, histogram, interval, profiles, qqplot, summary
Expand Down
Loading
Loading