Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
116 views

I have a data frame containing the specification for a set of regression models (regress_grid) with a column for different aspects of the model. I then use dplyr::rowwise() to estimate a model for ...
RichPatter's user avatar
0 votes
1 answer
71 views

I'm trying to forward arguments to dplyr functions in a function of my own cross_section(), namely to summarise(), group_by() and arrange() but I'm struggling to find the right pattern, particularly ...
Ramiro Magno's user avatar
  • 3,195
4 votes
1 answer
106 views

Is it possible in some way to force the evaluation order in a {tidypolars} pipe? For example: install.packages("tidypolars", repos = c("https://community.r-multiverse.org", '...
crestor's user avatar
  • 1,558
4 votes
2 answers
145 views

I am trying to evaluate some user-provided arguments in a specific data environment using the rlang quasi-quotation approach. In addition, I want to wrap the output in a data.frame / tibble. However, ...
const-ae's user avatar
  • 2,236
4 votes
3 answers
187 views

I want to create a custom function for the collapse package where I supply unquoted grouping variables like so: library(collapse) library(tidyverse) fgroup_by_no_entries <- function(df, ...) { ...
user63230's user avatar
  • 4,911
1 vote
1 answer
130 views

I'm trying to better understand tidy evaluation and the use of rlang, but there's a specific use case I can't figure out. Let's say I want to run a linear mixed model and save the output of one ...
user23485480's user avatar
1 vote
1 answer
62 views

I'm trying to write a function that would simply wrap around deparse() and substitute() like so: get_name <- function(x) { deparse(substitute(x)) } The point of get_name() is to return the ...
Harrison Jones's user avatar
3 votes
1 answer
103 views

outer_func uses tidy evaluation for col_rfs and dflt_flag, i.e. it is possible to do col_rfs = dplyr::starts_with("col"). library(magrittr) outer_func <- function(dat, col_rfs, dflt_flag)...
PalimPalim's user avatar
  • 3,068
0 votes
1 answer
61 views

Here is what I want to achieve library(dplyr) mtcars %>% dplyr::summarise( dplyr::across(mpg, ~ sum(.x) / sum(vs)) ) #> mpg #> 1 45.92143 if I have this function stored in an object, I ...
olivroy's user avatar
  • 849
1 vote
1 answer
73 views

In learning metaprogramming with R, I'm trying to understand the different concepts and mechanisms that form the tidy evaluation framework. I don't really understand the difference between expr() and ...
Ralph's user avatar
  • 224
0 votes
1 answer
65 views

I have a r script, named myrsciprt.R as follows: library(ggplot2) library(ggpubr) library(palmerpenguins) create_plots_pdf <- function(output_filename, group_name){ # Histogram example: ...
JustB's user avatar
  • 37
1 vote
2 answers
69 views

I've attached a simple reproducible example below. I'm currently working within a nested tibble with dynamic column names. I'm using the purrr::map() function to pass the column data into an anonymous ...
Michael Luu's user avatar
1 vote
1 answer
48 views

I am trying to create a plot function that can plot different colors for a column with factors if .f2=NULL, and an interaction of the .f1 and .f2 columns if the .f2 parameter is not NULL. The if ...
Robert's user avatar
  • 1,068
2 votes
3 answers
125 views

How can I iterate over functions that use tidy evaluation (via rlang's curly-curly)? Here's a basic example, where I attempt to iterate over column names using purrr::map(): library("dplyr") ...
pyg's user avatar
  • 842
2 votes
1 answer
155 views

What I'm trying to do I'm attempting to write a function that uses dplyr verbs and that takes an "arrow open dataset" as the first argument, and a column in that dataset as the second ...
Avery Robbins's user avatar
0 votes
1 answer
55 views

I want to write a simple function that takes a dataframe and a numeric column (a parameter e.g. called col as input. The name of the numeric column should be quoted (like "mpg"). I am having ...
Lenn's user avatar
  • 1,511
2 votes
1 answer
97 views

I am trying to write a function in R for re-creating a ggplot graph. The graph is using climate data, and I want to be easily able to remake it for 3 different climate scenarios (rcp column) and ...
abby23's user avatar
  • 25
1 vote
2 answers
75 views

I'm fairly new in working with R, so I might not be naming so things right ;-) I would like to plot the results of three different linear models. To do so, I loop over my column names, which I saved ...
tobix100's user avatar
0 votes
1 answer
46 views

Below is a pmap() operation that requires my data to be in wide format. I perform a few simulations each day and capture the max value per simulation as post_max. library(tidyverse) POST_SIMS <- 2 ...
Joe's user avatar
  • 3,836
1 vote
1 answer
33 views

I am creating a custom function that generates bar plots using ggplot2 and geom_col(). My objective is to enable the function to dynamically assign either a single color or a color based on a grouping ...
TarJae's user avatar
  • 80.2k
0 votes
1 answer
74 views

I'm trying to automate the production of .tex tables and I want to add in the add.lines section of stargazer a value called mean_outcome but I'm having trouble producing this value, I think I'm ...
Paula's user avatar
  • 701
0 votes
1 answer
76 views

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 ...
Jojostack's user avatar
  • 180
2 votes
2 answers
2k views

Consider the following structure: tmp_data <- structure( list( currency = c("EUR", "USD"), funding = c(50, 700)), class = c("tbl_df", "tbl", "...
balin's user avatar
  • 1,706
1 vote
1 answer
114 views

I am trying to label my facet_wrap titles based on an aggregation of data in my data frame. I am writing a function to plot different data sets, so I am using a function argument to select the column ...
apple's user avatar
  • 500
2 votes
1 answer
151 views

I am trying to build a GET request one row at a time from a dataframe where the possible parameters are a varied and large list, and the dataframe I'm passing to the function may not have the ...
ScottyJ's user avatar
  • 1,117
0 votes
1 answer
84 views

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 ...
ScottyJ's user avatar
  • 1,117
1 vote
1 answer
93 views

Question Why do I get inconsistent error messages in R from a function that uses non-standard evaluation, and what is the best way to control this / write the function? Initial setup that works as ...
ScottyJ's user avatar
  • 1,117
0 votes
1 answer
52 views

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 <- ...
sahuno's user avatar
  • 473
0 votes
2 answers
479 views

I have data with multiple observable variables (say, x,y,z), indexed by another set of variables (sect, and item). Each time I run an experiment I get such a set of observations. So for experiment &...
postylem's user avatar
  • 1,121
0 votes
1 answer
119 views

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(...
Oliver's user avatar
  • 1,331
0 votes
0 answers
39 views

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 ...
Tom's user avatar
  • 51
4 votes
1 answer
122 views

Little tidyeval question, I've got this function: coacross <- function(...) { coalesce(!!!across(...)) } And then if I do something like this: aa = tibble(a1 = c(NA, 1), a2 = c(2, NA), b = 3:4) %...
Juan C's user avatar
  • 6,148
2 votes
1 answer
94 views

Disclaimer: this is a very elemental question. I'll use an example to make it easier, but the question has nothing to do with the example itself. Supose you have a dataframe df: # A tibble: 5 × 4 ...
Ricardo Semião's user avatar
3 votes
3 answers
703 views

I am working on updating some older R code to make it use ggplot2's aes() now that aes_string() is deprecated. I admit I don't understand all of the details of tidy evaluation, but from what I do ...
bluemouse's user avatar
  • 512
0 votes
2 answers
323 views

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, ...
Tube's user avatar
  • 195
2 votes
1 answer
128 views

I would like to pass the names of several variables to a function that is using tidyeval. I know I can pass the vars like this: a_summary_fn <- function(the_data, the_group, vars) { the_data |...
itsMeInMiami's user avatar
  • 2,975
2 votes
2 answers
150 views

I have the following data: my_data <- structure(list(case_one = c("A", "B", "A", "B", "A", "B", "A", "B", "A&...
fschier's user avatar
  • 299
1 vote
1 answer
72 views

I'm chaining two functions together where both use the same column to perform some operation. I'd like to be able to specify this column as the input parameter only on the call to the first function ...
C.Robin's user avatar
  • 1,110
1 vote
1 answer
103 views

I have a function which is a wrapper around stringr::str_c(), and therefore receives any number of character vectors as input using the ... argument. The issue is that I would like to perform some ...
Matan Hakim's user avatar
1 vote
1 answer
97 views

I'm running into an issue passing a column being created in mutate to the the group_by function. here is some example data: set.seed(42) ## for sake of reproducibility w2_test <- data.frame(id=1:...
Alex Braga's user avatar
1 vote
1 answer
122 views

Say I have this data: d <- msleep %>% mutate(comfort_color_desk = sample(c(0,1), replace=TRUE, size=nrow(msleep)), comfort_color_chair = sample(c(0,1), replace=TRUE, size=...
C.Robin's user avatar
  • 1,110
2 votes
3 answers
354 views

I am writing a custom function that outputs the mean and sd of a field. I would like the .field argument to be evaluated in a tidyeval manner at some states and as a string at another stage. How can I ...
Joe's user avatar
  • 3,836
1 vote
1 answer
69 views

I am writing a function that makes ggplots with given data, and I am interested in setting a parameter that can call the different scales::label_* functions to change the outputs. For example, I want ...
mfg3z0's user avatar
  • 899
1 vote
1 answer
49 views

I am writing a function using tidyeval, and I ran into a problem while trying to check for NAs. I am writing a function to make plots using ggplot2 that looks something like: my_func <- function(...
mfg3z0's user avatar
  • 899
0 votes
1 answer
92 views

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 ...
mfg3z0's user avatar
  • 899
1 vote
1 answer
50 views

Just wondering what the current start of the art is for using tidyeval principles inside a function. Imagine we have two tibbles in our environment, and we want to pass their names to a purrr::map ...
tomw's user avatar
  • 3,281
1 vote
3 answers
253 views

I am trying to create a function and I want to reference a column I previously created inside the function with the {{}} and :=. How can I reference the "{{col}}_d" column? library(...
kmlewis15's user avatar
0 votes
1 answer
69 views

I have the data as below adsl <- structure(list(SUBGRPVAR1 = structure(c("F", "M", "M", "M", "F", "F"), label = "Sex"), ...
jkatam's user avatar
  • 3,465
1 vote
1 answer
432 views

I want to modify a list of columns. Each column has a list of conditions that need to be applied with a case_when. I tried the following: df <- tibble(value=c("a","b","c&...
Julio's user avatar
  • 13
2 votes
1 answer
1k views

I am trying to update some older plot-making code that gives the message: Warning message: `aes_string()` was deprecated in ggplot2 3.0.0. Please use tidy evaluation ideoms with `aes()` When I ...
bluemouse's user avatar
  • 512

1
2 3 4 5
10