[R] Cleaning up workspace
Prof J C Nash (U30A)
nashjc at uottawa.ca
Wed Oct 16 17:03:22 CEST 2013
In order to have a clean workspace at the start of each chapter of a
book I'm "knit"ing I've written a little script as follows:
# chapclean.R
# This cleans up the R workspace
ilist<-c(".GlobalEnv", "package:stats", "package:graphics",
"package:grDevices",
"package:utils", "package:datasets", "package:methods", "Autoloads",
"package:base")
print(ilist)
xlist<-search()[which(!(search() %in% ilist))]
print(xlist)
for (ff in xlist){
cat("Detach ",ff," which is pos ",as.integer(which(ff ==
search())),"\n")
detach(pos=as.integer(which(ff == search())), unload=TRUE) # ?? do
we need unload
}
rm(list=ls())
This appears to "work" fine in my system -- session info is below, but I
get 30 warnings of the type
30: In FUN(X[[2L]], ...) :
Created a package name, ‘2013-10-16 10:56:47’, when none found
Does anyone have ideas why the warnings are being generated? I'd like
to avoid suppressing them. Here's the session info.
R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.0.1
>
John Nash
More information about the R-help
mailing list