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...
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 ...
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
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...
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...
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...
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...
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...
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...
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...
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 ...
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)
...
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...
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...
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...
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...
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"...
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...
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...
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...
2
Solved
1 Next >
© 2022 - 2025 — McMap. All rights reserved.