nse Questions

2

Solved

I find myself writing this bit of code all the time to produce standard errors for group means ( to then use for plotting confidence intervals). It would be nice to write my own function to do this...
Schlegel asked 30/5, 2017 at 15:32

3

Solved

I want to create a function that takes up as the first argument the name of a data set, and as a second argument, part of a column's name from the dataframe. I then want to use glue to dynamically ...
Corporeal asked 29/5, 2024 at 8:8

4

Solved

aes_string had some convenient behaviours that I made use of when programming with ggplot2. But aes_string has been deprecated (noticeably since ggplot2 version 3.4.0 I believe). I am struggling wi...
Limburg asked 12/11, 2022 at 15:39

5

Solved

I want to use ggplot to loop over several columns to create multiple plots, but using the placeholder in the for loop changes the behavior of ggplot. If I have this: t <- data.frame(w = c(1, 2...
Cockloft asked 31/1, 2011 at 22:26

1

Solved

I'd like to use a utility function to check whether a given column exists within a given data.frame. I'm piping within the tidyverse. The best I've come up with so far is library(magrittr) columnE...
Stibnite asked 28/11, 2022 at 16:43

2

Solved

For some objects an attribute identifies a special column, for example the geometry column in an sf object. For conducting some calculations in dplyr it would be good to easily identify these colum...
Aguascalientes asked 11/11, 2022 at 12:48

2

Solved

Let us take a simple example data <- data.table::data.table(a = 1:10, b = 2:11) j <- quote(c("c") := list(a + 1)) data[, j, env = list(j = j)][] # a b c # <int> <int> &l...
Lockett asked 3/2, 2022 at 10:41

2

Solved

I'm writing a function where I supply a variable name as a symbol. At a different step in the function, I want to use the variable name as a string. Per the documentation, rlang::as_string "co...
Allodium asked 1/8, 2021 at 20:34

4

Solved

I want to rename a column inside a function with a name passed as an argument for this function. Basically, I have a function produce_data_frame <- function(name) { return(iris) } And I want...
Carnarvon asked 4/4, 2018 at 11:57

2

Many of R's functions with non-standard evaluation, e.g. with, subset, and transform, contain a warning like this: For interactive use this is very effective and nice to read. For programming howe...
Alcoholic asked 1/4, 2021 at 15:13

4

Solved

I want to use use the dplyr::group_by function inside another function, but I do not know how to pass the arguments to this function. Can someone provide a working example? library(dplyr) data(ir...
Guide asked 16/2, 2014 at 17:52

4

Solved

The following code renames first column in the data set: require(dplyr) mtcars %>% setNames(c("RenamedColumn", names(.)[2:length(names(.))])) Desired results: RenamedColumn cyl disp hp dr...
Hollyanne asked 13/3, 2017 at 17:20

2

Solved

I use a dynamic variable (eg. ID) as a way to reference a column name that will change depending on which gene I am processing at the time. I then use case_when within mutate to create a new column...
Lukey asked 26/11, 2020 at 16:19

3

Solved

I try to write a simple function wrapping around the dplyr::case_when() function. I read the programming with dplyr documentation on https://cran.r-project.org/web/packages/dplyr/vignettes/programm...
Rationality asked 29/12, 2017 at 13:9

6

Solved

I have a ggplot command ggplot( rates.by.groups, aes(x=name, y=rate, colour=majr, group=majr) ) inside a function. But I would like to be able to use a parameter of the function to pick out the ...
Walloping asked 10/3, 2014 at 19:17

1

Solved

I want to use mutate to give me predicted values based on pre-specified variables with a quadratic / polynomial function. I can easily do this with a linear formula like this: library(tidyverse) ...
Thiele asked 20/5, 2020 at 0:35

2

I'm updating an old script using the deprecated dplyr::filter_() to use dplyr::filter(). But I can't get it to work for empty filter strings anymore: Example: library(dplyr) my_df <- tibble::t...
Massasoit asked 15/5, 2020 at 14:32

2

Solved

A real question. Whenever I need to write dplyr functions, I play by the ear. I am aware of the curly-curly operator which simplifies a lot the task. https://www.tidyverse.org/blog/2019/06/rlang-0...
Mccullough asked 18/4, 2020 at 20:17

1

Solved

I'm trying to wrap my head around the different quo/unquo syntaxes and when each should be used. I am mostly writing functions that pass a dataframe and columns to use as argument -- to plot using...
Shroud asked 27/1, 2020 at 19:3

2

Solved

I have defined a list of expressions containing arguments I want to pass to a dplyr::filter call. library(tidyverse) # using tidyr 1.0.0 cond_filter <- list(expr(1 > 0), # condition to sele...
Photogenic asked 17/11, 2019 at 10:26

3

Solved

Consider a tibble where each column is a character vector which can take many values -- let's say "A" through "F". library(tidyverse) sample_df <- tibble(q1 = c("A", "B", "C"), q2 = c("B", "B"...
Mousetail asked 11/10, 2019 at 17:43

4

Solved

In the following example, why should we favour using f1 over f2? Is it more efficient in some sense? For someone used to base R, it seems more natural to use the "substitute + eval" option. librar...
Efthim asked 6/4, 2018 at 21:0

2

Solved

I am having trouble running non-standard evaluation (nse) expressions with the tidyr package. Basically, what I want to do is to expand two columns that may be identical or not to achieve a datafr...
Karmenkarna asked 23/9, 2019 at 20:0

4

Solved

I have a data.frame like this: value condition 1 0.46 value > 0.5 2 0.96 value == 0.79 3 0.45 value <= 0.65 4 0.68 value == 0.88 5 0.57 value < 0.9 6 0.10 value > 0.01 7 0.90 value &g...
Limeade asked 23/4, 2019 at 8:49

2

Solved

I'd like to use dplyr's new NSE notations (version >= 0.6) for a dynamic filter on my data. Let's say I have the following dummy dataset: df = data_frame(x = 1:10, y = 10:1, z = 10 * runif(10)) ...
Saprolite asked 11/9, 2017 at 11:20

© 2022 - 2025 — McMap. All rights reserved.