Questions tagged [tidyeval]

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/

473 questions
1
vote
2 answers

Arrange function in dplyr 0.7.1

I am trying to use the new quo functionality while writing a function utilizing dplyr and ran into the following issue: df <- tibble( g1 = c(1, 1, 2, 2, 2), g2 = c(1, 2, 1, 3, 1), a = sample(5), b = sample(5) ) To arrange the dataframe by…
jonmaestro
  • 13
  • 3
1
vote
0 answers

Error using tidyeval quo() with gather()

I am trying to run gather() on data frames, and programmatically assign the .key column name using !!quo(). But I keep getting 'Error: Invalid column specification'. I even found a closed ticket where it shows that it should work…
1
vote
1 answer

Function with dplyr, tidyr and ggplot

How can I make a function that takes a column and uses that in dplyr, tidyr and ggplot? df <- data.frame(date_col = c(1,1,2,2,3,4,4,5,5), col_a = c('a','b','a','b','a','a','b','a','b'), val_col = runif(9)) How do…
Rickard
  • 3,600
  • 2
  • 19
  • 22
0
votes
0 answers

how to evaluate textInput inside a Shiny Module as arguments

I am working on a Shiny app that serves as an interface for the gtsummary package. One of the features I've added is the ability to apply functions like add_p() to the generated tables, and it's working as expected. However, I encountered a…
Jojostack
  • 181
  • 9
0
votes
0 answers

how to convert a list of objects names into a vector of strings in R

Usecase: when exporting excel sheets with different datasets you would naturally pass them through a list so that you modulise your code and not to do reptitive work. To get tab names you need to convert those object names into a vector of strings.…
Ahmad I
  • 11
  • 1
0
votes
1 answer

Is there a better way to use NSE in a function to concatenate dataframe columns?

Background I'm trying to get my grip on meta-programming methods in Advanced R, and not being a programmer by background, it is taking some effort. I am trying to write functions to manipulate dataframe columns without quoting (tidyverse style). …
ScottyJ
  • 945
  • 11
  • 16
0
votes
1 answer

function arguments not found in call environment

I'm creating a function which takes column names as arguments and to plot survival plots. however my arguments can't be found in the calling function. thanks in advance for your help plt_survive <- function(data_in, time_var, event_var,…
sahuno
  • 321
  • 1
  • 8
0
votes
1 answer

Wrapper function to purrr::map() over column names using tidyeval function

I've got a function that uses tidyeval to refer to a column name, but also needs to access that column name as a string. The code for that works fine, see below (though improvements welcome, as_name(enquo(x)) seems clunky). But I can't figure out…
Oliver
  • 1,098
  • 1
  • 11
  • 16
0
votes
0 answers

Unsure what is wrong with summarize() in my custom function

I have a list of tables that I need to make using different variables, and I want to make a function that will let me make the tables differently each time by passing through different variables as arguments. There are many table outputs that need…
Tom
  • 11
  • 1
0
votes
2 answers

how to avoid tidy evaluation (especially double curly brace) in user define function in r?

id <- 1:30 x<-rnorm(30,1,10) y<-rnorm(30,1,10) data<-data.frame(id,x,y) add<-function(data, y_1, y_2){ data<-dplyr::mutate(data, higher_one = dplyr::case_when( {{y_1}} > {{y_2}} ~ "1", …
Tube
  • 177
  • 5
0
votes
1 answer

Tidy eval for `by` in `dplyr::_join

I am writing a function to join two datasets using dplyr::_join where the by terms are parameters passed in without quotes. I have seen quite a few solutions to this issue, but all seem to be dated and/or deprecated: Use rlang::quo_text or…
mfg3z0
  • 561
  • 16
0
votes
1 answer

map does not work on vector which i am trying to use

I have the data as below adsl <- structure(list(SUBGRPVAR1 = structure(c("F", "M", "M", "M", "F", "F"), label = "Sex"), SUBGRPVAR2 = structure(c("Y", "N", "Y", "N", "Y", "N"), label = "Completers of Week 8 Population Flag")), row.names = c(NA,…
jkatam
  • 2,691
  • 1
  • 4
  • 12
0
votes
0 answers

map with tidy eval with paste

I need to run lm on nested data and use map with lm. But I put it in a function to have a different set of independent variables in the model. The code looks like…
m45ha
  • 399
  • 1
  • 9
0
votes
1 answer

how to use is.na() with dplyr, when column name is stored as string?

I'm new to tidy evaluation- although some things make sense, I usually just try different combinations of {{}}, !! + quo, sym() etc. But I can't get is.na() to work? here's an example: column <- "Sepal.Length" iris_na <- rbind(iris,…
Wojty
  • 59
  • 5
0
votes
3 answers

How to avoid inlining expressions when combining map with tidyeval modelling wrappers

I am trying to combine flexible modelling functions (using tidyeval) and then mapping over data in a nested dataframe (and attempting to learn tidy evaluation along the way). I am running into the problems of inlining expressions with the captured…
Matt
  • 1
  • 1