Error: could not find function "%||%" (percent pipe pipe percent) [duplicate] - r

This question already has an answer here:
How to find the package name in R for a specific function?
(1 answer)
Closed 2 years ago.
Due to the characters, I'm having a hard time googling for which package the %||% function comes from.
I have tried googling the string literal, as well as 'percent bar bar percent' and similar.

It is present in rlang package. See
?rlang::`%||%`
It behaves like dplyr::coalesce but for NULL values instead of NAs.

Related

similar to SAS where we have macro variable syslast which return the last created dataframe , do we have a similar thing in r [duplicate]

This question already has an answer here:
How to assign the result of the previous expression to a variable?
(1 answer)
Closed 19 days ago.
Similar to SAS where we have system macro variable syslast which returns the last created dataframe, do we have a similar thing in r
You can access the most recent returned value using .Last.value

R: Looping over vector of strings for function input [duplicate]

This question already has answers here:
R ~ Vectorization of a user defined function
(2 answers)
Closed 2 years ago.
I have a vector of inputs in R and a function f.
inputs <- c('input1','input2','input3',...,'input10')
I want to obtain output <- c(f(input1),f(input2),...,f(input10)) without writing this out.
How can I do this in an efficient manner, and without using a for loop? Also, I'd like to do this without referring to the subscript on input (I just numbered it for the sake of this question).
Further, f('input1') does not work while f(input1) does. How can I resolve this?
Hope Vectorize could help
Vectorize(f)(inputs)

R operator: <<- [duplicate]

This question already has answers here:
Why is using `<<-` frowned upon and how can I avoid it?
(2 answers)
Closed 8 years ago.
What's the difference between "<-" and "<<-" in R? I have read the help file in R. But I still don't understand their difference. Could any one provide an example? Thanks a lot!
used inside a function, the standard "<-" operator defines a variable inside this function and the variable will not be available outside.
Using "<<-" enables your function to define a variable outside, aka in the global environment, for further use.
That is quite useful in fact!

determine when an R base function was added [duplicate]

This question already has answers here:
Figure out what version of R a function was introduced in
(2 answers)
Closed 9 years ago.
Is there a way to determine rather easily when an R function was added (what version number). Take for instance when were:
paste0 and browseVignettes added?
I'm not really looking for when these were added but a way to see when they were added.
Converting my comment to an answer as requested:
You can use the news() function
news(grepl("paste0", Text))
Go here: http://cran.r-project.org/src/base/NEWS.html
paste0 was in 2.15.0 and browseVignettes was 2.13.0 but it doesn't seem to mention browseVignettes.

Masked functions in R [duplicate]

This question already has answers here:
What does "The following object is masked from 'package:xxx'" mean?
(2 answers)
Closed 5 years ago.
This is a newbie question in R. If you have two libraries in R with same function name (and one masking the other) then how do you use the masked function.
A concrete example:
Both UsingR and QRMlib have the function QQPlot(), and UsingR's QQplot is masking that of QRMlib. How can I use the QQplot function of QRMlib.
Thank you
Addition: Just found out that QRMlib::QQplot() works, thus modifying the question that I found in the web. What if they don't have a namespace in which case the above approach will not work.
Link to the original question posed in google:
https://stat.ethz.ch/pipermail/r-help/2005-March/067710.html
UsingR::QQPlot() and/or QRMlib::QQPlot()
Try to load preferred library last, since it will mask the "unwanted" function...
All the best!

Resources