Sometimes after playing around in R for a while, I find myself thinking, "What have I done?". Which boils down to "What's the difference between the objects I currently have in my R session and those that were loaded from my .RData when I started R".

So I bashed this out in five minutes, just to test the principles.

differ <- function(file){
  load(file)
  inFile <- ls()
  inMemory <- ls(1)

  inBoth <- inFile[inFile %in% inMemory]

  for(thing in inBoth){
    if(identical(get(thing,1),get(thing))){
      cat(paste("Object :",thing," identical\n"))
    }else{
      cat(paste("Object :",thing," changed\n"))
    }
  }

  list(inFile,inMemory,inBoth)
}

Eventually I'd make it display objects only in the .RData (these would be things deleted since load), only in environment 1 (things newly created since load), those in both but unchanged, and those in both yet changed.

But then I thought, "Hey, its coffee time, lets see if anyone on R-help has done this already and when I get back refreshed it'll be done".

 I'm also not sure if 'get()'ting the things is the right thing to do.

Barry

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to