R operator: <<- [duplicate] - r

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!

Related

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)

Is there a function in R that reproduce the squeeze function of Matlab? [duplicate]

This question already has an answer here:
R: Efficiently remove singleton dimensions from array
(1 answer)
Closed 5 years ago.
I'm looking for a function in R that reproduce exactly what the squeeze function of Matlab does. Does anybody know it?
(I'd have thought that it would have been incumbent on an asker to explain what squeeze actually does -- drops singleton dimensions.)
See the help on the drop function in R; this also drops singleton dimensions.

How to see all methods, objects, dataframse, etc of a package in R? [duplicate]

This question already has answers here:
Show names of everything in a package
(4 answers)
Closed 9 years ago.
My question is similar to this question and in fact, is answered there. But because it took me a lot effort to find the answer there. I preferred to create a new more organized one and answer it myself.Now the question is:
If I want to see all methods, dataframes, etc of a package that I only know its name, what should I do to access them very easily?
Just enter this code:
help(package='PACKAGENAME', help_type='html')
for example to see all you have in the R basic package, stats:
help(package='stats',help_type='html')

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