What is the bquote() function in R?
Overview
The bquote() function in R is used to return quoted arguments or give a partial substitution of values of the arguments that are passed to it. The exception to this rule is when the values are wrapped in .()
Syntax
bquote(expr)
Parameter value
The bquote() function takes a parameter value expr, which represents a language object.
Return value
The bquote() function returns a language object.
Code example
# creating a variablea <- 2# using the bquote() function to quote the argumnent passed to abquote(a == a)# using bquote() function for values wrapped in ".()"bquote(a == .(a))bquote(a == .(a + a))
Code explanation
- Line 2: We create a variable called
a. - Line 5: We quote the value of the variable
a, using thebquote()function. - Lines 8–9: We implement the
bquote()function for the values wrapped in.().