Questions tagged [quasiquotes]

70 questions
2
votes
1 answer

Make a function (which uses data.table) that supports both quoted and unquoted arguments and then works in purrr::map (or lapply)

I have the following function which works only for quoted variables: library(data.table) # version 1.11.8 library(purrr) col_count <- function(dt, vars = NULL){ dt[, .N, by = vars] } I have successfully created basically the same function which…
Telaroz
  • 173
  • 1
  • 7
2
votes
2 answers

R: convert elements of list into expression from function input

I am writing a function, where the inputs are arguments and name of another function. I would like to convert these arguments and function name into an unevaluated expression or call. For example, if this is the call to the function: huh_fun( …
Daniel D. Sjoberg
  • 8,820
  • 2
  • 12
  • 28
2
votes
2 answers

using quasiquotation with `$` operator

I am trying to use rlang to write custom functions. Although I can do this when functions involve data argument, I have trouble how to use quasiquotations properly when the functions require vectors and I need to use the $ operator. Here is a toy…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
2
votes
1 answer

What is the rule for nested quasiquote processing in Clojure?

What is nested quasiquote processing rule in Clojure? I am writing a Lisp variant where symbols are hygienic (auto gensymed). I got single level quasiquote working with auto gensym, but I am not sure when two or more level of nesting gets in. How to…
John Doe
  • 2,225
  • 6
  • 16
  • 44
2
votes
1 answer

Passing on missing quasiquotation arguments

I am trying to use the quasiquotation to pass a raw variable name to a function, that passes it on to another function. However, the argument is optional, so I need to test if the 1st function was not given the argument and passed on that missing…
MrGumble
  • 5,631
  • 1
  • 18
  • 33
2
votes
1 answer

rxDataStep "transform" argument using quasi-quotation

I am trying to use the quasi-quotation syntax (quo, exprs, !!, etc.) as well as the foreach function to create several new variables by means of a named list of expressions to be evaluated inside the rxDataStep function, specifically, the transforms…
M. Meiring
  • 21
  • 2
1
vote
1 answer

Is there a way to access variable fields in quote variable interpolation?

I have a tuple with 5 elements and I want to include each one of them in the quote!{...} block. I tried accessing the fields directly in the quote!{} block in a few ways without success: let tuple = (1, true, -3, 4., "five"); quote! { #tuple.0 }; …
Matteo
  • 135
  • 2
  • 7
1
vote
3 answers

Quasiquotes in Scalafix

Here is Spark 2.4 code using unionAll import org.apache.spark.sql.{DataFrame, Dataset} object UnionRewrite { def inSource( df1: DataFrame, df2: DataFrame, df3: DataFrame, ds1: Dataset[String], ds2: Dataset[String] ): Unit =…
mvasyliv
  • 1,214
  • 6
  • 10
1
vote
1 answer

using quasiquotation in a function with summarize in dplyr

I'm trying to write a function that can take column names as strings assigned to variables and produce a summarized output for them like so my_function <- function(my_df, columnA,columnB){ summ_df <- my_df %>% group_by(cyl) %>% …
Al Bro
  • 383
  • 5
  • 15
1
vote
1 answer

How to compile QuasiQuoter during runtime?

I have a 'QuasiQuoter' which is useful in source code in Haskell, but also as a standalone application. So, I need to be able to run QuasiQuoter During the compile time in Haskell - [myGrammar|someCommand|] In runtime (runtime compilation) in shell…
Přemysl Šťastný
  • 1,676
  • 2
  • 18
  • 39
1
vote
1 answer

Listing all fixity declarations in Quasiquote monad

I would like to list all fixity declarations in Quasiquote monad so I am able to pass all the infix operators from Haskell grammar to my Quasiquote grammar. Is there any method in template-haskell which allows me to do so please? I can't find…
Přemysl Šťastný
  • 1,676
  • 2
  • 18
  • 39
1
vote
2 answers

R meta programming: Paste logic expressions with function call

I'd like to have a function to paste logical expressions paste_logic(a == b, c > q, f < g, sep = and) # should return # expr(a == b & c > q & f < g) I would also like to lazily unquote during ruturning (not in the function call), ideally control…
englealuze
  • 1,445
  • 12
  • 19
1
vote
1 answer

Using a declaration quoter in a where statement

I am implementing a DSL that is based on using standard haskell functions/combinators to build database queries. From an implementation POV I decided to represent variables in the query like this: newtype Variable = Var { fromVar :: Text } this…
Fabian Schneider
  • 799
  • 1
  • 13
  • 40
1
vote
2 answers

{testthat} `quasi_label` with `expect_match` throws "Error: invalid argument type"

I am new to {testthat} and am building tests for a function that modifies strings and is expected to produce a specific output for certain input patterns. As a example (reprex below), add_excitement adds an exclamation point to its input string.…
maia-sh
  • 537
  • 4
  • 14
1
vote
3 answers

Behavior of "unquote" when used as the second to last symbol in a quasiquoted proper list

I am trying to produce the list (1 unquote 2) using quasiquote. I have tried this: `(1 unquote 2) However, in Racket, MIT Scheme and Chez Scheme, I get a dotted list: '(1 . 2). So I tried this: `(1 'unquote 2) However, I get (1 'unquote 2). I…
Flux
  • 9,805
  • 5
  • 46
  • 92