Please use this tag for questions about using tidy evaluation within the tidyverse framework. For more information please refer to this handbook: https://tidyeval.tidyverse.org/
Questions tagged [tidyeval]
473 questions
0
votes
2 answers
Create new column using tidy evaluation on the left and right of mutate in R
I know there are many questions regarding tidy evaluation in R. However, I couldn't figure out a solution to this seemingly easily problem.
I have this data.frame
structure(list(Date = c("25.02.2020", "26.02.2020", "27.02.2020",
"28.02.2020",…

Lenn
- 1,283
- 7
- 20
0
votes
1 answer
How to correctly glue together prefix/suffix in a function call RHS
I'm attempting to iterate over a list of column suffixes and, for each, call a function to perform a bunch of summarises. My problem is how to correctly build the variable name and have R interpret it correctly. I've tried various combinations of…

Ian
- 1,507
- 3
- 21
- 36
0
votes
1 answer
Curly curly operator inside survey function
I have a survey data with weight column like this dummy sample:
df <- structure(
list(
device = c(
"Digital",
"No Device",
"No Device",
"Digital",
"Digital",
"No Device",
"Digital",
"Digital",
…

DanG
- 689
- 1
- 16
- 39
0
votes
0 answers
Pmap over tidyeval function
I have created the following function to count the number of terminations in a company by variable in the dataframe.
emp_term_var <- function(data, colName, year = "2015") {
colName <- enquo(colName)
term_test <- data %>%
…

Taren Shaw
- 89
- 6
0
votes
1 answer
Passing enquo expression to subfunction
This question is related to Passing variables to functions that use `enquo()`.
I have a higher function with arguments of a tibble (dat) and the columns of interest in dat (variables_of_interest_in_dat). Within that function, there is a call to…

IrisOren
- 69
- 1
- 1
- 6
0
votes
1 answer
issues with dplyr group_by within a custom function; related to tidyeval?
I'm trying to write a function to make a long three way contingency table use group_by and summarize from dplyr. I start with a tibble containing 3 factor variables: year, mammogram and sp.
> c_table_fn <- function(x){
+ factors %>%
+…
0
votes
1 answer
Assign into variable from string
I would like to dynamically create a variable name from a string and then assign in a value. I believe I should be able to easily do this with {rlang} but haven't been able to work it out from package docs, Advanced R, and searching. Below is a…

maia-sh
- 537
- 4
- 14
0
votes
0 answers
Mutate column inside function on both sides of equation
Been trying to do something very simple, but I'm still having troubles with tidyeval. I have a numeric column from a dataframe and want to turn it into a string, let's say:
id code
1 10
2 14
And I want to turn code into a string in this case,…

Juan C
- 5,846
- 2
- 17
- 51
0
votes
1 answer
Turning dplyr code into function that accepts columns as arguments
I've been fighting trying to understand tidyeval and the use of quo, quos, sym, !!, !!! and the like. I made some attempts, but couldn't generalize my code so it accepts a vector of columns and applies text processing to those columns on a…

Juan C
- 5,846
- 2
- 17
- 51
0
votes
2 answers
tidyeval: !! with purrr::map anonymous functions
I would like to create a single column by conditional logic across multiple columns. This is a minimal reproducible example. As you can see, the double bang seems to cause evaluation of the .x before the anonymous function is defined. Any ideas for…

user2376418
- 3
- 1
0
votes
1 answer
How to get specific values out of a list of values passed to one argument of a UDF with tidyeval
I used tidyeval to write a short function which takes grouping variables as an input, groups the mtcars dataset and counts the number of occurences per group:
test_function <- function(grps){
mtcars %>%
group_by(across({{grps}})) %>%
…

mafiale
- 41
- 4
0
votes
1 answer
Question on R programming with dplyr and tidy evaluation
Folks I have a couple of questions about how tidy evaluation works with dplyr
The following code produces a tally of cars by cylinder using the mtcars dataset:
mtcars %>%
select(cyl) %>%
group_by(cyl) %>%
tally()
With output as expected:
# A…
0
votes
1 answer
How to get object name as a string using tidyevaluate?
I need to pass column names to the plotting function. The problem is that my column names are in the arguments and I don't know how to extract those as text.
Here is code that works, but I need to get the strings dynamically from the…

MesRot
- 133
- 1
- 9
0
votes
1 answer
How to mutate variable with tidyevaluation
I'm trying to create a function that prints a plot when user inputs data and variables what to plot. My current problem is that group/subgroup columns may be numeric so I need to mutate them into factors before plotting. I'm trying to do it with…

MesRot
- 133
- 1
- 9
0
votes
1 answer
Adding a point based on data to ggplot
I have this issue where I have to add a "target" point to an existing plot, based on a value in the data.
For example, in the reprex - to make a point at (2010, 605). (target year, 110% of 2008 profit)
I know I can calculate before plotting ... but…

dcurrie27
- 319
- 3
- 14