Skip to content

Commit adad21d

Browse files
committed
add symbolic = TRUE argument that optionally allows to turn off the symbolic interpretation of formula parts (discussed in #339)
1 parent b93f10d commit adad21d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

R/tinyformula.R

+8-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,17 @@ tinyformula = function(formula, facet = NULL) {
6969
))
7070
}
7171

72-
tinyframe = function(formula, data, drop = FALSE) {
72+
tinyframe = function(formula, data, drop = FALSE, symbolic = TRUE) {
7373
## input
7474
## - formula: (sub-)formula
7575
## - data: model.frame from full formula
7676
if (is.null(formula)) return(NULL)
77-
names = sapply(attr(terms(formula), "variables")[-1L], deparse, width.cutoff = 500L)
77+
if (symbolic) {
78+
names = sapply(attr(terms(formula), "variables")[-1L], deparse, width.cutoff = 500L)
79+
} else {
80+
rhs = formula[[2L]]
81+
names = deparse(rhs, width.cutoff = 500L)
82+
data[[names]] = with(data, eval(rhs))
83+
}
7884
data[, names, drop = drop]
7985
}

0 commit comments

Comments
 (0)