Questions tagged [quasiquotes]

70 questions
0
votes
1 answer

Assign into variable from string

I would like to dynamically create a variable name from a string and then assign in a value. I believe I should be able to easily do this with {rlang} but haven't been able to work it out from package docs, Advanced R, and searching. Below is a…
maia-sh
  • 537
  • 4
  • 14
0
votes
0 answers

Rendering multiple Rmarkdown reports with parameters fails with "Error: `:=` can only be used within a quasiquoted argument" when data.table is used

Good morning everybody, as stated above, I’m trying to render multiple Rmarkdown reports with different parameters for each report. Basically I have a folder of .csv files, which I have to clean up. I have packed all the steps in an .Rmd file,…
tim
  • 427
  • 1
  • 6
  • 10
0
votes
2 answers

Use quasiquotation for formula syntax in a user-created function?

When I run this code: # Create example data df <- tibble(age=rnorm(10), income=rnorm(10)) make_model <- function(response_var, df){ # Create formula form <- as.formula(response_var ~ .) # Create model model <- lm(form ,…
max
  • 4,141
  • 5
  • 26
  • 55
0
votes
1 answer

F# code quotations: can I define my own concrete and abstract syntax?

In Haskell I can use the quasiquoter to produce a custom AST using concrete syntax defined by custom parser, as described here: https://wiki.haskell.org/Quasiquotation Is this possible in F#?
runeks
  • 1,745
  • 2
  • 17
  • 26
0
votes
2 answers

using quasiquotation in functions with formula interface

I want to write a custom function that can take bare and "string" inputs, and can handle both functions with and without the formula interface. custom function example # setup set.seed(123) library(tidyverse) # custom function foo <-…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
0
votes
2 answers

using column names in functions that rely on quasiquotation

I am writing a custom function that is expected to work with both unquoted and "quoted" inputs. I can implement it using rlang. But it doesn't seem to work when "quoted" arguments are provided using colnames. Any ideas on how this can be resolved?…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
0
votes
1 answer

Quasiquoter concrete syntax for visible type application

In the following snippet, the first argument to foo, SNat @n, is assembled manually: [e|foo $(appTypeE (conE 'SNat) n')|] where n' = litT . numTyLit . fromIntegral $ n Is there concrete TH quasiquoter syntax for this? I.e. I'd like to write…
Cactus
  • 27,075
  • 9
  • 69
  • 149
0
votes
1 answer

Trouble with quotes and quasi-quotation and regular expressions inside a function in R

I am trying to write a function which uses gsub to find and replace certain strings. I have 10+ excel spreadsheets with a list of monetary values using standard Swedish separators for thousands and decimals, i.e. a decimal is noted by a comma and…
Kuns
  • 25
  • 3
0
votes
1 answer

Lifting string with Scalameta

I would like injecting a method 'toCSV' to parse a class into CSV String. My function take two paramters : Seq[String] : header Seq[Seq[Any]] : fields My macro : class model extends scala.annotation.StaticAnnotation { inline def apply(defn:…
user2931656
  • 253
  • 2
  • 3
  • 13
0
votes
1 answer

rlang: The assignment form of quo, documentation, finding of. Or something

A lot of the help page examples for quo take forms like this one, assigning an output of quo to quo: quo <- quo(letters) quo <- quo(toupper(!! quo)) quo eval_tidy(quo) It seems clear that these assignments do not overwrite the quo function (since…
andrewH
  • 2,281
  • 2
  • 22
  • 32
1 2 3 4
5