Questions tagged [quosure]
79 questions
2
votes
1 answer
What's the difference between `as.name` and `sym`?
I'm trying to wrap my head around standard, non-standard evaluation, quosures, etc. In many examples, I see passed string variable being transformed into dplyr-usable form either with as.name or with sym of rlang package.
Are they interchangeable…

JelenaČuklina
- 3,574
- 2
- 22
- 35
2
votes
1 answer
R dplyr Quosure logic when function input is a variable
I'm trying to get a custom group_by function working using quosure. It works fine when the input into the function is the name of a field. However, if I want to create a variable that contains the name of the field to insert into the function, I get…

Morgan Ball
- 760
- 9
- 23
2
votes
2 answers
using non-standard evaluation with formula
I'm creating a package that uses non-standard evaluation to keep track of the meaning of columns. The package passes a data frame among functions, which do various things do the same set of columns. Nonstandard evaluation works great for…

Drew Steen
- 16,045
- 12
- 62
- 90
1
vote
3 answers
How does eval and parse get evaluated inside across in dpyr?
I already posted this as an issue in dplyr's repo on github, and they said that across is not a good fit for this type of problem, but I want to post here to see if anyone can give me insight into why this doesn't actually work.
I'm trying to write…

Voy
- 99
- 4
1
vote
2 answers
is_quosure(x) error when forwarding ... inside map
I would like to define a wrapper to an inner function.
The idea is to repeat random sampling that uses one of r* base function (eg runif, rnorm, etc.) and let the user easily change this inner function and define custom ones.
The example below show…

Vincent Bonhomme
- 7,235
- 2
- 27
- 38
1
vote
1 answer
Error: Quosures can only be unquoted within a quasiquotation context
I am setting up a function to make it easier to run weights:wtd.chi.sq on a number of columns simultaneously.
Here is my sample data:
library(weights)
data_in <- read_table2("Q50_1 Q50_2 Q38 Q90 pov gender wgt1 wgt2
never always Yes 2 …

NewBee
- 990
- 1
- 7
- 26
1
vote
1 answer
R: In a function using dplyr, how do I check to make sure that an argument name is not quoted before proceeding?
Long story, short: I have a function where the argument grouping.var = record_id will work, but grouping.var = "record_id" will return incorrect data with no error. So I want my function to check that the name passed to the argument is not in…

Bart
- 473
- 6
- 15
1
vote
2 answers
Forcing dplyr to evaluate passed symbol / quosure when conflicting with existing column name
Problem
I want to string of a column name to dplyr::arrange in a form am <- "cyl". The purpose is to sort by column cyl.
Desired outcome
dplyr::arrange(mtcars, cyl)
Attempts
am <- "cyl"
1) rlang::quo
dplyr::arrange(mtcars,…

Konrad
- 17,740
- 16
- 106
- 167
1
vote
1 answer
Joining two data sets using as_label / as_name instead of quo_name within dplyr's left_join
Following from the answer on join datasets using a quosure as the by argument which suggests using: quo_name in order to join tables using quosures; I would like to arrive at identical result using as_name / as_label as quo_name's is currently…

Konrad
- 17,740
- 16
- 106
- 167
1
vote
3 answers
Explain quosure to a dummy
I'm trying to make a function that will produce a plot when given passed a variable to plot.
The variable is selected from a dropdown - hence aes_string.
make_plot <- function(data, plot_var) {
plot_var <- enquo(plot_var)
…

dcurrie27
- 319
- 3
- 14
1
vote
1 answer
How to pass a filter statement as a function parameter in dplyr using quosure
Using the dplyr package in R, I want to pass a filter statement as a parameter in a function. I don't know how to evaluate the statement as code instead of a string. When I try the code below, I get an error message. I'm assuming I need a quosure or…

oatmilkyway
- 429
- 1
- 6
- 17
1
vote
2 answers
How to test if a function argument is a "quosurable" name?
I'm making a function that should be able to handle multiple classes for its first argument: formulas, characters, tidy-selection, var names... The goal is then to use tidyselection with tidyselect::vars_select, except with bare formulas.
The…

Dan Chaltiel
- 7,811
- 5
- 47
- 92
1
vote
1 answer
Mimicking a secondary tidy dots argument in an R function
I'm looking to create a function that accepts a list of (data frame) variables as one of its parameters. I've managed to get it working partially, but when I get to the group_by/count, things fall apart. How can I do this??
## Works
f1 <-…

Paul Lemmens
- 595
- 5
- 14
1
vote
0 answers
dplyr passing variables to a function to dynamiclly arrange cols
I'm attempting to dynamically arrange a dataframe by passing a list of variable to use in ascending order first and one variable in descending order (last in the arranging order). each iteration selecting the top rows and storing another dataframe.…

Dr.Upchi
- 11
- 3
1
vote
1 answer
dplyr group_by multiple function arguments via Non Standard Evaluation
I was reading dplyr's vignette trying to figure out how to use dplyr in my function codes. Mid way through it talks about how to use enquos on ... in order to pass multiple arguments to group_by.
a short example of how it would work
grp <-…

Justin Landis
- 1,981
- 7
- 9