Questions tagged [non-standard-evaluation]
156 questions
1
vote
2 answers
dplyr programming: unexpected behavior of filter
I am trying to use dplyr in the programming way: filter behavior with quoted variables are not understandable.
After several attempts to analyze the real data I had created a following dummy data.
dt <- data.frame(
sex = rep(c("F","M"), 50),
…

NT_
- 641
- 1
- 5
- 13
1
vote
2 answers
programming with dplyr::arrange in dplyr v.0.7
I am trying to get my head around the new implementations in dplyr with respect to programming and non standard evaluation. So the verb_ functions are replaced by enquo of the argument and then applying !! in the regular verb function. Translating…

Edwin
- 3,184
- 1
- 23
- 25
1
vote
1 answer
get names of quoted list without evaluation
I've got a quoted list
quote(list(orders = .N,
total_quantity = sum(quantity)))
(that I eventually eval in the j part of a data.table)
What I would like is to extract the names of that list without having to evaluate the expression…

RoyalTS
- 9,545
- 12
- 60
- 101
1
vote
2 answers
How to get . in a formula correctly interpreted inside dplyr::do?
I have the following data frame:
input.df <- dplyr::data_frame(x = rnorm(4),
y = rnorm(4),
`z 1` = rnorm(4))
I would like to do a multiple regression for each column with the other columns…

mauna
- 1,098
- 13
- 25
1
vote
1 answer
What I'm doing wrong here when trying to convert an nlmrt object to an nls object
I am trying to convert an "nlmrt object to an "nls" object using nls2. However, I can only manage to do it if I write explicitly the names of the parameters in the call. Can't I define the parameter names programmatically? See the reproducible…

DeltaIV
- 4,773
- 12
- 39
- 86
1
vote
1 answer
SE issue with conditional mutate
I'm trying to do a simple conditional with mutate.
The code should create a new variable called "gender" based on two variables from same dataframe.
sample <- data.frame(
client = c("john", "peter", "hanna", "lisa"),
id = c(100, 400, 650,…

Prometheus
- 1,977
- 3
- 30
- 57
1
vote
1 answer
R dplyr - get variable name as string in mutate/summarise
I have been trying unsuccessfully to extract the name of a variable that was passed to a function in dplyr::mutate(). Below is a short example where I want to create a function that returns the string "mpg" inside mutate:
# mtcars dataset with…

Christoph
- 575
- 4
- 15
1
vote
0 answers
NSE of an environment variable in R
Question is in regards to validating the existence of an environment, and if not found either create the enviornment, or return the variable name passed for whatever reason. Essentially this is a function I'm using in a series of unsupervised…

Carl Boneri
- 2,632
- 1
- 13
- 15
0
votes
0 answers
Callers visibility of changes and mutations to the arguments in the non strict evaluation strategy?
All the strict evaluation strategies described here talk about if the caller would see the changes and/or mutations made to the function arguments within the scope of the called function. However, no such discussion is had in non-strict evaluation…

figs_and_nuts
- 4,870
- 2
- 31
- 56
0
votes
0 answers
Create multiple csv based on groups of a categorical feature in a dataframe in R with split and map2 functions
I have been trying to create a simple function with a two arguments in R that takes a dataset as an example and a categorical feature, and based on that specific feature, stores in a folder ("DATA") inside the parent working directory multiple csv…

ATB
- 3
- 1
0
votes
2 answers
Function not using conditional ensym() as expected
I am trying to create a function that conditionally uses an argument, which when used, is a column of a df.
Here is an example function:
new_fx <- function(data, x, y, z=NULL){
x <- ensym(x)
y <- ensym(y)
if ( !is.null(z)){
z <- ensym(z)
…

scott.pilgrim.vs.r
- 179
- 8
0
votes
1 answer
R eval(predvars, data, env) object not found by passing a pameter in a function
My reproducible example is as follows;
please do not bother at all the underlying meaning of the calculations (none, actually) because it is just an extract of my real dataset;
train <- structure(list(no2 = c(25.5, 31.2, 33.4, 29.9, 31.8),
…

maxbre
- 161
- 9
0
votes
2 answers
dplyr::slice_max - Hand over order_by as calculated string
I want to hand over the name of a variable as a string to the order_by argument of dplyr::slice_max(), but I'm getting weird results. Using the iris data here.
library(dplyr)
lastcol <- first(colnames(iris))
My expected result would be a df/tibble…

Timm S.
- 5,135
- 6
- 24
- 38
0
votes
1 answer
Update lists elements programmatically looping through the lists names
I need to update lists elements programmatically looping through the lists names in R.
Is there a way to do that using some sort of Non-Standard Evaluation or another method?
Pseudo-code of a minimum example:
x = list(a=1)
y = list(a=3)
…

GitHunter0
- 424
- 6
- 10
0
votes
1 answer
using lapply with list of arguments on dplyr functions that uses data masking
when programming using dplyr, to programmatically use variables in dplyr vers from function arguments, they need to be references by {{var}}
This works well, but I would like to use lapply with the var argument supplied in a list. This is throwing…

Niels Krarup
- 11
- 2