Questions tagged [lazyeval]
17 questions
17
votes
5 answers
Variables as default arguments of a function, using dplyr
Goal
My goal is to define some functions for use within dplyr verbs, that use pre-defined variables. This is because I have some of these functions that take a bunch of arguments, of which many always are the same variable names.
My understanding:…

Axeman
- 32,068
- 8
- 81
- 94
10
votes
3 answers
How to feed a list of unquoted column names into `lapply` (so that I can use it with a `dplyr` function)
I am trying to write a function in tidyverse/dplyr that I want to eventually use with lapply (or map). (I had been working on it to answer this question, but came upon an interesting result/dead-end. Please don't mark this as a duplicate - this…

leerssej
- 14,260
- 6
- 48
- 57
4
votes
2 answers
Lazy eval, dplyr "filter" and NAs
I am having some silly problem using lazy evaluation and dplyr.
I'm trying to filter some NAs and don't know why the lazyeval version doesn't work. Probably I'm missing something, but I can't find it. Is that so, or is it a bug?
Here is a minimum…

Elijah
- 414
- 3
- 8
4
votes
1 answer
R lazyeval: pass parameters to dplyr::filter
I think this questions has multiple other variations (eg: here, here and perhaps here) - probably even an answer somewhere.
How to provide parameters to the filter function.
library(dplyr)
library(lazyeval)
set.seed(10)
data <-…

user3375672
- 3,728
- 9
- 41
- 70
4
votes
1 answer
Error: Package or namespace load failed
I am getting the following error when I am loading a few libraries in R:
library(forecast)
Error : object ‘f_eval’ is not exported by 'namespace:lazyeval'
In addition: Warning message:
package ‘forecast’ was built under R version 3.3.2
…

ab90hi
- 435
- 1
- 4
- 11
2
votes
1 answer
R lazy evaluation ifelse logical condition
I have the following data.table:
dtable <- data.table(column1 = c(1, 2, 3, 5, 6, 7, 8),
column2 = c(1, 1, 1, 5, 5, 6, 8),
column3 = c(7, 8, 9, 0, 9, 2, 3))
I would like to make something like the following…

Jaime Caffarel
- 2,401
- 4
- 30
- 42
2
votes
2 answers
Passing column name inside a function using dplyr
I am aware of using lazyeval inside function in order to refer to column names with dplyr but am stuck. In general, when creating a function that uses dplyr which also references column names from function arguments, what is the most idiomatic way…

DavidH
- 619
- 2
- 8
- 15
1
vote
2 answers
How to pass formulas or quosures in dplyr verbs R as arguments
I am not able to use formulas or quosures in filter expressions in dplyr.
a_table <- data_frame(key = rep(letters[1:2], each = 2),
value = replace(runif(4), mod(1:4, 2) == 1, NA))
a_cond <- quo(not(is.na(value)))
filter(a_table,…

Diego-MX
- 2,279
- 2
- 20
- 35
1
vote
1 answer
How should I use the uq() function inside a package?
I'm puzzled by the behaviour of the uq() function. The behavior is not the same when I use uq() or lazyeval::uq().
Here is my reproducible example :
First, I generate a fake dataset
library(tibble)
library(lazyeval)
fruits <- c("apple", "banana",…

PAC
- 5,178
- 8
- 38
- 62
1
vote
1 answer
How to pass '...' argument into an interp() formula within lazyeval
I'm trying to do some parametrised dplyr manipulations. The simplest reproducible example to express the root of the problem is this:
# Data
test <- data.frame(group = rep(1:5, each = 2),
value = as.integer(c(NA, NA, 2, 3, 3, 5,…

pfabri
- 885
- 1
- 9
- 25
0
votes
1 answer
can't find a function from loaded package
I created a local package with personal functions to be easily used within R. One of these is aimed to be used in the lidR package within a wrapper function (i.e. grid_metrics). For this reason I took the scheme of this script as a reference,…

Nico
- 191
- 1
- 6
0
votes
2 answers
How to implement mutate-like chain evaluation?
Dplyr's mutate function can evaluate "chained" expressions, e.g.
library(dplyr)
data.frame(a = 1) %>%
mutate(b = a + 1, c = b * 2)
## a b c
## 1 1 2 4
How can this be implemented? Quick glance at dplyr's source code reveals the basic…

Tim
- 7,075
- 6
- 29
- 58
0
votes
1 answer
How to mutate dataframe inside do with dplyr
Inside the do I am calling a mutate_ with reference to the original dataframe. The problem is that I can't get access to that dataframe inside the mutate. This has to do with lazyeval package, but I haven't been able to figure it out. Thank you…

Diego-MX
- 2,279
- 2
- 20
- 35
0
votes
2 answers
How to pass column name in ggplot facet_wrap in a function
How to pass column name of a data frame in ggplot facet_wrap or fill/colour in a function? I looked up lazyeval but didn't figure out a way.
x="class"
ggplot(mpg, aes(displ, hwy, col=x)) + geom_point() + facet_wrap(x)
In this example, why didn't…

santoku
- 3,297
- 7
- 48
- 76
0
votes
1 answer
lazyeval not finding `C_logit_link` when using binomial in the glm function
I'm really scratching my head here. I really don't understand what is going on. This is a MWE, but the actual code and purpose is more complex then this. So the code:
library(dplyr)
ds <- mutate(iris, Species = as.numeric(Species == 'setosa'))
ds…

Luke W. Johnston
- 954
- 9
- 17