Re: [R] How to perform package cleanup when R session is ending?

2020-12-18 Thread Jiefei Wang
Thank you! This solution works! I actually tried reg.finalizer but it didn't work when it is a part of the package code, so I thought this is not the right function. Your example is very helpful. Putting the function inside the package initializer makes the finalizer works as I wish. Not sure why i

Re: [R] How to specify year-month-day for a plot

2020-12-18 Thread Bill Dunlap
Have you tried abline(v=as.Date("2019-04-06"), col="red") -Bill On Fri, Dec 18, 2020 at 9:29 AM Gregory Coats wrote: > I need to be able to draw and label a vertical line, representing the date > of some arbitrary event. The date of the first entry is 2013-11-29. How > would I draw, and labe

Re: [R] How to specify year-month-day for a plot

2020-12-18 Thread Gregory Coats via R-help
I need to be able to draw and label a vertical line, representing the date of some arbitrary event. The date of the first entry is 2013-11-29. How would I draw, and label a red vertical line at 2019-04-06? Greg gcdf<-read.table(text="2013-11-29 19.175 2014-01-20 10.072 2014-02-12 10.241 2014-03-

Re: [R] How to perform package cleanup when R session is ending?

2020-12-18 Thread Bill Dunlap
E.g., as in a package containing just the following R code: $ cat testFinalizer/R/zzz.R envir <- new.env() cleanup <- function(e) { message("cleanup(", format(e), ")") if (!isTRUE(envir$cleaned)) { message("cleaning ", format(e)) envir$cleaned <- TRUE } else {

Re: [R] How to perform package cleanup when R session is ending?

2020-12-18 Thread Bill Dunlap
Have you tried using reg.finalizer(..., onexit=TRUE)? -BIll On Fri, Dec 18, 2020 at 7:29 AM Jiefei Wang wrote: > Hi, > > I am looking for a way to clean up my package resources before R is ended. > It looks like the .onUnload function would not be helpful as it would not > be called before R is

[R] How to perform package cleanup when R session is ending?

2020-12-18 Thread Jiefei Wang
Hi, I am looking for a way to clean up my package resources before R is ended. It looks like the .onUnload function would not be helpful as it would not be called before R is ended. This behavior has been described in the document: *Note that packages are not detached nor namespaces unloaded at t