Questions tagged [quosure]
79 questions
1
vote
1 answer
Dynamic variable names using SE mutate function
I don't know how to cut dynamic variables into groups within a for loop.
df is the data frame that contains clm_april - clm_sept variables that are double. Also I would like to put different names for new columns.
Groups which are different for…

Luka
- 113
- 1
- 6
1
vote
1 answer
Using dplyr quosures with mutate()
Reading the Programming with dplyr guide, I get a unexpected error.
In fact, trying the examples with summarize works quite right, but if I try similar things with mutate, the code won't run.
Here is my code :
df =…

Dan Chaltiel
- 7,811
- 5
- 47
- 92
1
vote
0 answers
using non-standard evaluation with formula Bis
Non-Standard evaluation in R. I want to send a formula to a function that uses lm.
I have a data frame with one response: y and many predictors. I will fit a model inside a function. The function will receive a filtering criteria as a string and…

Harlan Nelson
- 1,394
- 1
- 10
- 22
1
vote
1 answer
R - rlang - Working with delayed evaluation
Trying to solve the following use case:
I have a full data set (mydf) which I want to dplyr::group_by with different variable sets according to the entries of another set of combinations of variables (mysplits). The issue is, my mysplits data.frame…

jameselmore
- 442
- 9
- 20
1
vote
1 answer
Great than sign and quosure producing error
I am encountering an issue when using dplyr in a function. When filtering based on a quosure, the > sign appears to cause an issue where no data are returned.
For example:
temp_df <- data.frame(
startdate_c = as.Date(c("2011-08-08", "2007-09-01",…

GenericNameNumber
- 28
- 6
0
votes
1 answer
Problem using the Tidyverse Filter Function to Create My Own Functions
I appreciate any help that can be given. I am working with a data set on bacterial growth. I have collected the data, which has eight variables, and used 'pivot_longer' for optimal plotting. I have three different treatments: experimental, negative…
0
votes
0 answers
creating a nested tibble
I would like to create a tibble that contains a nested tibble, but also a column outside the nested tibble that refers to a column header within the nested tibble. This is what I mean
library(tidyverse)
tib <- tibble(dat = list(tibble(xvar = 1,…

Andrew
- 111
- 4
0
votes
0 answers
Error: Quosures can only be unquoted within a quasiquotation context, function with plotly
i have created a function with a plot result, but i have this error message:
Error: Quosures can only be unquoted within a quasiquotation context.
Bad:
list(!!myquosure)
Good:
dplyr::mutate(data, !!myquosure)
when i erase the enquo() function, it…

Daniela saba rosner
- 31
- 3
0
votes
1 answer
How to assign a quosure to another object?
I want to change the name of some argument.
Following the guidelines, I should use lifecycle::deprecate_warn and then attribute the old name to the new name.
However, in my function, the argument is normally used with quosures, so the attribution…

Dan Chaltiel
- 7,811
- 5
- 47
- 92
0
votes
1 answer
Selecting columns from dataframe programmatically when column names have spaces
I have a dataframe which I would like to query. Note that the columns of that dataframe could change and the column names have spcaes. I have a function that I want to apply on the dataframe columns. I figured I could programmatically find out what…

user3510503
- 308
- 2
- 4
- 13
0
votes
1 answer
Using quosure inside ggplot function annotate
I have produced the below scatter plot function.
scatter_fun<-function(data,xval,yval,xlabel,ylabel, labels){
xval <- enquo(xval)
yval <- enquo(yval)
ggplot(data, aes(!!xval, !!yval))+
geom_smooth(method=lm, se=FALSE)+
…

awz1
- 419
- 2
- 12
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,…

Thomas Price
- 81
- 7
0
votes
1 answer
How to incorporate the suffix of an output$suffix name into an input$suffix_rows_selected function in R shiny?
I am trying to get the suffix of an output$suffix name in R Shiny and incorporate it into the input$suffix_rows_selected function. The drilldown table is coming empty. Would someone have any idea of what am I doing wrong?
Function that I am trying…

Suzy
- 51
- 3
0
votes
1 answer
`enquo` of column name variable not working with `dplyr::filter`
Suppose we have the following data frame:
df <- data.frame(x=1:10, odd=rep(c(T,F), 5))
And a variable that stores the name of the odd column:
odd_col <- 'odd'
How do I use odd_col to reference the odd column in a dplyr::filter operation?
From what…

merv
- 67,214
- 13
- 180
- 245
0
votes
2 answers
Mapping over a list of variables using quosures
Lets say I want to use purrr::map to create a list of models, each using a different variable as a predictor. I would imagine I could do something like this:
library(tidyverse)
myvars <- vars(cyl, disp, hp)
list_of_models <- map(myvars, function(x)…

kmace
- 1,994
- 3
- 23
- 39