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
0
votes
1 answer

Passing variable names in function and using them to create dynamic plot and labels in R

(I am newbie in R). I have created a outer function with 3 inner functions that preprocess data & plot. Issues I am facing is in using country name dynamically - in passing them on y axis and also use them inside labs for titles/subtitles. Adding…
ViSa
  • 1,563
  • 8
  • 30
0
votes
1 answer

Summarise multiple functions at once using tidyeval in dplyr 1.0

Say we have a data frame, library(tidyverse) library(rlang) df <- tibble(id = rep(c(1:2), 10), grade = sample(c("A", "B", "C"), 20, replace = TRUE)) we would like to get the mean of grades grouped by id, df %>% group_by(id) %>% …
ThomasJc
  • 131
  • 9
0
votes
1 answer

Issues in passing variable names as arguments from outer function to inner function in R?

I am trying to automate a process and creating one outer function to run several smaller inner functions but function that have variable names as arguments are causing errors: When I run below function on its own then it works fine: gapminder <-…
ViSa
  • 1,563
  • 8
  • 30
0
votes
1 answer

How to summarize by sets of grouping variables in R and dplyr?

I want to group a data frame using different sets of grouping variables. For each group I want to count the number of observations (or summarize in any other way) and then collect all results in one data frame. Important: I want to define the sets…
robust
  • 594
  • 5
  • 17
0
votes
1 answer

Change value in place in a tibble using column names

I am trying to change the values of a tibble column in a place using a function. However, I am not managing it. Perhaps somebody could help. I made a simple reproducible example: noga2 <- tibble(a = c(1,12), b=c(12,3)) iot_test <- function(data,…
arnyeinstein
  • 669
  • 1
  • 5
  • 14
0
votes
2 answers

Refer to a variable via paste0() within a call to ggplot

Have read this post already, I still suspect my solution is in there somewhere. I would like to refer to a variable name by pasting the variable name together. In this case the breaks argument to…
Doug Fir
  • 19,971
  • 47
  • 169
  • 299
0
votes
1 answer

Tidyeval in a non-quasiquotation context (psych::describeBy(group))

I am trying to make a function that will return a gt table of the results of the common psych::describe() and psych::describeBy() functions. the problem is that describeBy() expects the group argument to be of the form data$vector rather than just…
Andrew McCartney
  • 191
  • 2
  • 10
0
votes
1 answer

Error using dplyr::group_by() in function within boot::boot() function during bootstrapping

I am currently trying to run a bootstrap analysis on some data where the end result is to get bootstrap confidence intervals around proportions of count data. For example, my current data that I am trying to bootstrap will take this form…
0
votes
1 answer

How can I take the first input of ...?

I want to create a function where the first input of create_df gets turned into the number 1 using tidyeval. Here it should be only the cyl column. How do I pull the first "input" of ...? library(dplyr, quietly = T) create_df <- function(...){ …
John-Henry
  • 1,556
  • 8
  • 20
0
votes
1 answer

How to write use quos in a formula in R?

I am trying write a function which creates a new column by multiplying two other columns, with the names of all three columns being given as (string) parameters to the function. I was thinking I could write something like this: A <- data.frame(x =…
ClownsENT
  • 155
  • 1
  • 8
0
votes
1 answer

R Dynamically filter rows in dataframe based on unique combination of listed columns

I have a large dataset (49 columns with 16000 rows) in long format. Ultimately, I need to filter the dataset by unique combinations of user defined specific columns in order to plot other dynamically chosen columns. The plotting will be done using…
melmo
  • 757
  • 3
  • 15
0
votes
2 answers

Get all combinations of a character vector

I am trying to write a function to dynamically group_by every combination of a character vector. This is how I set it up my list: stuff <- c("type", "country", "color") stuff_ListStr <- do.call("c", lapply(seq_along(stuff), function(i) combn(stuff,…
0
votes
2 answers

Tidyeval and apply family to add new variables to a dataframe

I'm trying to write a function to automate the creation of some new variables using tidyverse tools. I figured out my problem involves tidyeval, but I haven't quite figured out where I went wrong in the code below, which is just reproducing the…
Jack Landry
  • 138
  • 8
0
votes
1 answer

Tidy Evaluation not working with mutate and stringr

I've trying to use Tidy Eval and Stringr togheter inside a mutate pipe, but every time I run it it gives me an undesirable result. Instead of changing the letter 'a' for the letter 'X', it overwrite the entire vector with the column name, as you can…
John P. S.
  • 367
  • 3
  • 17
0
votes
0 answers

NSE dplyr::left_join failing due to incompatible types

I'm writing a function which helps me clean up field trial data. I'm writing it using tidyeval NSE to challenge myself and ensure that the function is easy to use if I return to it. I think I've nearly got it, but when running my test frame I get a…