Quantcast
Channel: How do you use "
Browsing latest articles
Browse All 8 View Live

Answer by Rtist for How do you use "

I use it in order to change inside purrr::map() an object in the global environment.a = c(1,0,0,1,0,0,0,0)Say I want to obtain a vector which is c(1,2,3,1,2,3,4,5), that is if there is a 1, let it 1,...

View Article



Answer by Carlos Cinelli for How do you use "

The <<- operator can also be useful for Reference Classes when writing Reference Methods. For example:myRFclass <- setRefClass(Class = "RF", fields = list(A = "numeric", B = "numeric", C =...

View Article

Answer by Matthew Wise for How do you use "

On this subject I'd like to point out that the <<- operator will behave strangely when applied (incorrectly) within a for loop (there may be other cases too). Given the following code:fortest...

View Article

Answer by hadley for How do you use "

<<- is most useful in conjunction with closures to maintain state. Here's a section from a recent paper of mine:A closure is a function written by another function. Closures areso-called because...

View Article

Answer by Shane for How do you use "

It helps to think of <<- as equivalent to assign (if you set the inherits parameter in that function to TRUE). The benefit of assign is that it allows you to specify more parameters (e.g. the...

View Article


Answer by lcgong for How do you use "

f <- function(n, x0) {x <- x0; replicate(n, (function(){x <<- x+rnorm(1)})())}plot(f(1000,0),typ="l")

View Article

Answer by Dirk is no longer here for How do you use "

One place where I used <<- was in simple GUIs using tcl/tk. Some of the initial examples have it -- as you need to make a distinction between local and global variables for statefullness. See for...

View Article

How do you use "

I just finished reading about scoping in the R intro, and am very curious about the <<- assignment.The manual showed one (very interesting) example for <<-, which I feel I understood. What...

View Article

Browsing latest articles
Browse All 8 View Live




Latest Images