Questions tagged [quosure]
79 questions
1
vote
1 answer
r rlang: using is_quosure on tidyselect helper
Suppose that you have an argument in a R function that could be either:
a raw tidyselect helper such as contains("a"), starts_with("a") etc,
a list of quosures with the helpers, with vars(contains("a")).
How do you check within the function if…

Matifou
- 7,968
- 3
- 47
- 52
1
vote
1 answer
R Quasiquotation & tidyeval for dynamic variable references in R in own functions
I'm trying to get my head around using quasiquotation from the tidyverse in R in my own functions. I've read this one here: Passing a list of arguments to a function with quasiquotation and the whole thing here: https://tidyeval.tidyverse.org/
But I…

deschen
- 10,012
- 3
- 27
- 50
1
vote
2 answers
Unquote quosure outside quasiquotation context
I am defining a function to get the predicted values of a regression model with survey data for different subgroups(subpopulations). I use the svyglm function from the survey package.
My problem concerns handling the subset option in the svyglm…

Stephan
- 113
- 14
1
vote
1 answer
How to use quotation and unquotation when calling tidyverse functions?
I don't understand how to use expressions and quotation/unquotation/quasiquotation in the context of the R tidyverse. In the following example, I thought that using the unquote (!!) operator would allow me to generate the required arguments for…

John D
- 467
- 1
- 5
- 10
1
vote
1 answer
Non standard evaluation setting names R
I am trying to repeatedly call a function (specifically Seurat::DimPlot), where one of the the arguments is a named list (cells.highlight). I am planning to use purrr::imap to do make the call. I have a named list, where each of the element of the…

HowYaDoing
- 820
- 2
- 7
- 15
1
vote
3 answers
R: Error in new_quosures(NextMethod()) : could not find function "new_quosures"
Consider a data frame:
data = data.frame(a=c(1,1,1,2,2,3),
b=c("apples", "oranges", "apples", "apples", "apples", "grapefruit"),
c=c(12, 22, 22, 45, 67, 28),
d=c("Monday", "Monday", "Monday", "Tuesday",…

Bruce Wayne
- 471
- 5
- 18
1
vote
1 answer
Recall variable value using quosure
I would like to recall the value of the variable dynamically in a loop. Here is an example of the problem. I am new to tidyverse and not great at quos and quosures.
library (tidyverse)
mtcars.df <- mtcars
mtcars.df <- mtcars.df %>%…

KP1
- 129
- 2
- 8
1
vote
0 answers
r - Printing plots from list returns quosure error
I have generated a series of plots using ggplot and lapply, like so:
makeplot <- function(data){
require(ggplot2)
require(dplyr)
ggplot(data,aes(x=num,y=cat3, fill=cat3)) +
facet_wrap(~cat2)
# etc...
}
plot_list <-…

rbanick
- 31
- 5
1
vote
1 answer
With dplyr and enquo my code works but not when I pass to purrr::map
I want to create a plot for each column in a vector called dates. My data frame contains only these columns and I want to group on it, count the occurrences and then plot it.
Below code works, except for map which I want to use to go across a…

Chris Umphlett
- 380
- 3
- 15
1
vote
1 answer
How to filter dataframe using several function parameters that may or may not be passed in? (R; dplyr)
I'm writing a function that takes several parameters, strings or vectors of strings that correspond to attributes I'd like to filter on. I'd also like to write my function so that when a filter attribute isn't specified, it is simply ignored and the…

dad
- 1,335
- 9
- 28
1
vote
1 answer
Quosure with in a nested function
I am struggling to write a function fun2 that uses fun1... and keep getting errors. I have written a simplified example below. It is the first time I deal with "tidy evaluation" and not sure to understand the in and outs of it.
Example…

r_mvl
- 109
- 5
1
vote
1 answer
Why can't I unquote this quosure?
I'm reading through some notes on quasiquotation here: https://dplyr.tidyverse.org/articles/programming.html.
After my first read, I've tried a few things out. One in particular has me confused:
x <- "foo"
q <- quo(x)
print(x)
expr:…

Al R.
- 2,430
- 4
- 28
- 40
1
vote
1 answer
How to pass multiple group_by arguments and a dynamic variable argument to a dplyr function
I am trying to pass multiple group_by arguments to a dplyr function as well as a named variable. In understand that I need to use a quosure for dplyr to understand the variables i am passing to it. The following code works fine:
quantileMaker2 <-…

robbieNukes
- 89
- 1
- 12
1
vote
2 answers
Moving from deprecated summarize_ to new summarize in dplyr
I have a function that calculates the means of a grouped database for a column which is chosen based on the content of a variable VarName. The current function uses dplyr::summarize_, but now I see this is deprecated, and I want to replace it before…

iod
- 7,412
- 2
- 17
- 36
1
vote
1 answer
Inverse of quo() in dplyr
Using the new quosure syntax for dplyr 0.7.4, I believe I should be able to do something like !!quo(1) (expecting 1), yet it returns the error
library(dplyr)
!!quo(1)
Error in !quo(1) : invalid argument type
Why doesn't this work? (Note that in…

sirallen
- 1,947
- 14
- 21