One way to implement this functionality is with a task manager callback:

watch <- function(varname) {
  old <- get(varname)

  changed <- function(...) {
    new <- get(varname)
    if (!identical(old, new)) {
      message(varname, " is now ", new)
      old <<- new
    }
    TRUE
  }
  invisible(addTaskCallback(changed))
}

a <- 1
watch("a")
a <- 2


Hadley

On Wed, Feb 16, 2011 at 9:38 AM, Alaios <ala...@yahoo.com> wrote:
> Dear all I would like to ask you if there is a way in R to monitor in R when 
> a value changes.
>
> Right now I use the sprintf('my variables is %d \n, j) to print the value of 
> the variable.
>
> Is it possible when a 'big' for loop executes to open in a new window to 
> dynamically check only the variable I want to.
>
> If I put all the sprintf statements inside my loop then I get flooded with so 
> many messages that makes it useless.
>
> Best Regards
> Alex
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to