Skip to content

Commit

Permalink
DS-1526 update calls to AllVariablesNames to pass dataframe
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehoare committed Sep 15, 2017
1 parent ce4e552 commit 871bd3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/estimationdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ EstimationData <- function(formula = NULL,
unfiltered.weights <- weights
## Selecting the relevant variables from the data frame (unless imputation is being used).
## Remove backticks if present
variable.names <- sub("^[`]([[:print:]]*)[`]$", "\\1", AllVariablesNames(formula), perl = TRUE)
variable.names <- sub("^[`]([[:print:]]*)[`]$", "\\1", AllVariablesNames(formula, data), perl = TRUE)
labels <- Labels(data[, variable.names], show.name = TRUE)
# Removing cases with entirely missing data
some.data <- !apply(is.na(data[, variable.names, drop = FALSE]), 1, all)
Expand Down
7 changes: 4 additions & 3 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GetData <- function(formula, data, auxiliary.data)
{
data.provided <- !is.null(data)
CheckForUniqueVariableNames(formula)
variable.names <- AllVariablesNames(formula)
variable.names <- AllVariablesNames(formula, data)
if (!data.provided) # Extracting the data from the environment
{
data <- environment(formula)
Expand Down Expand Up @@ -57,12 +57,13 @@ GetData <- function(formula, data, auxiliary.data)
#' with a dollar sign are surrounded by backticks. Any such variables that already
#' contain backticks will have those backticks escaped.
#' @param formula An object of class \code{\link{formula}}.
#' @param data An object of class \code{\link{data.frame}}
#' @importFrom flipU AllVariablesNames
#' @export
DataFormula <- function(formula)
DataFormula <- function(formula, data = NULL)
{
formula.str <- paste(deparse(formula), collapse = "")
var.names <- AllVariablesNames(formula)
var.names <- AllVariablesNames(formula, data)

# We sort names from longest to shortest since we will be substituting by name
sorted.indices <- sort(sapply(var.names, nchar), decreasing = TRUE, index.return = TRUE)$ix
Expand Down
4 changes: 3 additions & 1 deletion man/DataFormula.Rd

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

0 comments on commit 871bd3f

Please sign in to comment.