similar to: Run package code on R shutdown?

Displaying 20 results from an estimated 10000 matches similar to: "Run package code on R shutdown?"

2004 Jun 10
1
tryCatch() and preventing interrupts in 'finally'
With tryCatch() it is possible to catch interrupts with tryCatch(). Then you can use a 'finally' statement to clean up, release resources etc. However, how can I "protect" against additional interrupts? This is a concern when the hold down Ctrl+C and generates a sequence of interrupts. Example: tryCatch({ cat("Press Ctrl+C...\n"); Sys.sleep(5); }, interrupt =
2002 Nov 09
1
Calling function with proto in Rinternals.h
(Tried this query on r-help with no luck, maybe someone here can help?) I would like to call the 'RFinalizerEx' function that appears in Rinternals.h using ".Call". It worked for me in the past, but now I get an error message something like: 'call function name not in call table'. I'm using the 1.6.1 rpm from CRAN. Anyone know what's going on? Thanks. Tim --
2020 Apr 03
4
The finalizer of the externalPtr does not work when closing R?
Hi all, I found that the finalizer of the externalPtr is not called when R is quitting. However, manually calling GC() works fine. This behavior is observed on devel R 2020-04-02 r78142 on Win and R 3.6.3 on Ubuntu. I make a reproducible package here: https://github.com/Jiefei-Wang/example Here is the detail of how to reproduce the problem, I create a temporary file in the package root path and
2005 Jun 10
1
Exiting R and package detachment?
Hi, is there away to assure that a package is detached when R quits? I know about .Last(), but that requires the user to setup that function. What I am looking for is a way for the package to do this itself, without asking the user to edit "their" .Last(). From ?setHook I know that: "...when an R is finished, packages are not detached and namespaces are not unloaded, so
2004 Jul 27
2
Incorrect display of b[hat((a))] expression in plots
Hi, I am not sure if this is a bug or a non-implement feature of text-drawing functions with TeX-style expression, but hat() and some of its equals does not get the right "bounding boxes" if they are put in sub- or superscripts. For instance, for the expression 'b[hat(a)]' the hat() seems to shift 'hat(a)' too much to the right of 'b'. Try the below example and
2013 May 24
1
Problem with Rboolean in c++ code
I am trying to use R_RegisterCFinalizerEx to ensure some c++ object is properly deleted after use. However, I run into some problems when trying to pass in the third argument which is an Rboolean. The line 'R_RegisterCFinalizerEx(p, finalizer, TRUE);' generates the following error when trying to compile using R CMD SHLIB: g++ -I/usr/share/R/include -DNDEBUG -fpic -O2 -pipe
2011 Sep 14
2
External pointers and an apparent memory leak
I'm using external pointers and seemingly leaking memory. My determination of a memory leak is that the R process continually creeps up in memory as seen by top while the usage as reported by gc() stays flat. I have isolated the C code: void h5R_allocate_finalizer(SEXP eptr) { Rprintf("Calling the finalizer\n"); void* vector = R_ExternalPtrAddr(eptr); free(vector);
2013 Nov 03
1
on.exit() & sys.on.exit(): Calling them via eval() does not work as hoped
Why does the following eval() call on sys.on.exit() not return what I expect/evaluate in the proper environment? foo <- function() { cat("foo()...\n"); on.exit( message("exiting") ) cat("sys.on.exit():\n") res <- sys.on.exit() print(res) cat("eval(sys.on.exit()):\n") expr <- quote(sys.on.exit()) print(expr) res <- eval(expr)
2016 May 14
2
R external pointer and GPU memory leak problem
My question is based on a project I have partially done, but there is still something I'm not clear. My goal is to create a R package contains GPU functions (some are from Nividia cuda library, some are my self-defined CUDA functions) My design is quite different from current R's GPU package, I want to create a R object (external pointer) point to GPU address, and run my GPU function
2004 Oct 15
1
Building package compatible w/ R v1.9.1 and R v2.0.0?
Hi, just in the process of updating my packages for R v2.0.0 and I have not had time to followed the R v2.0.0 discussions so maybe my questions have already been answered. A concern I have is that when creating packages they should be backward compatible with R v1.9.x for a while until all users and computers has migrated to R v2.0.x. It is pretty straightforward to setup my packages so that
2004 Nov 15
1
UseMethod call with no arguments
Dear R developers, I will ask a very straightforward question concerning UseMethod's future, because people depending on my code wonder what will happen to it next. In R v2.0.1 NEWS it says o The undocumented use of UseMethod() with no argument is now formally deprecated. and in the R v2.0.1 help(UseMethod) it says 'UseMethod' accepts a call with no arguments and tries to
2016 Sep 15
1
Finalizer execution order question
Given an externalptr object 'pool' which protects an R object 'prot': # SEXP prot = (a dynamically updated list with handles) SEXP pool = R_MakeExternalPtr(p, R_NilValue, prot); R_RegisterCFinalizerEx(pool, fin_pool, TRUE); WRE explains that 'prot' remains in existence as long as 'pool' is around. Does this also mean 'prot' still exists when the
2002 Aug 18
1
Adding argument 'flush' to read.table() too...
What about adding the argument 'flush=FALSE' to read.table() for the option to ignore trailing elements on each row? This feature already exists in scan(), which is called internally by read.table(): flush: logical: if `TRUE', `scan' will flush to the end of the line after reading the last of the fields requested. This allows putting comments after the last
2002 Jul 08
2
Methods/package for working with sets and intervals
Before reinventing the wheel, is there a package for working on (nice) sets and intervals, where one can for instance check if a set of intervals contains a scalar, taking the union and intersection of some intervals etc? Example: # Defining the set i = [1,2) + [3.5, 10] i <- c(1,2, 3.5, 10) attr(i, "include") <- c(TRUE, FALSE, TRUE, TRUE) x <- 0:12 # Get
2002 Aug 23
5
quick xtable questions
Hi, I'm creating a lot of tables in a file for inclusion in a Latex document. When I try to compile that document there is an error "too many unprocessed floats." Is there a way to correct this? Also, in a Latex table I want R to put in a $\beta$ in the caption, but it puts a weird system character instead of the \b Brian
2002 Aug 06
1
write.table() adds unnecessary spaces to right align integer column
When using write.table() to write data frames the integer columns are padded with unnecessary spaces (0x20) so that these columns are right align if you look at them in a text editor. However, I think it is quite a vast of file size. For instance, I am reading a tab-delimited 4200kb microarray data file and writing it back verbatim using write.table() and it becomes 5100kb, a 20% increase. Is this
2014 Oct 27
1
proper use of reg.finalizer to close connections
Hi all, I have a question about finalizers... I have a package that manages state for a few connections, and I'd like to ensure that these connections are 'cleanly' closed upon either (i) R quitting or (ii) an unloading of the package. So, in a pared-down example package with a single R file, it looks something like: ##### BEGIN PACKAGE CODE ##### .CONNS <- new.env(parent =
2006 Apr 05
1
predict.smooth.spline.fit and Recall() (Was: Re: Return function from function and Recall())
Hi, forget about the below details. It is not related to the fact that the function is returned from a function. Sorry about that. I've been troubleshooting soo much I've been shoting over the target. Here is a much smaller reproducible example: x <- 1:10 y <- 1:10 + rnorm(length(x)) sp <- smooth.spline(x=x, y=y) ypred <- predict(sp$fit, x) # [1] 2.325181 2.756166 ...
2024 Apr 25
1
Big speedup in install.packages() by re-using connections
On Thu, 25 Apr 2024 14:45:04 +0200 Jeroen Ooms <jeroenooms at gmail.com> wrote: > Thoughts? How verboten would it be to create an empty external pointer object, add it to the preserved list, and set an on-exit finalizer to clean up the curl multi-handle? As far as I can tell, the internet module is not supposed to be unloaded, so this would not introduce an opportunity to jump to an
2003 Aug 21
1
how to specify format of floats for the output file
I'd like to write some numbers to an external file that looks "pretty" (e.g, decimal points aligned, same number of decimals). For example, if using sprintf(), "%5.1f" can be used to specify the format of the float to be printed on screen. How can I do the same if I want to write an output file instead? I have tried cat and write.table, but none of them worked so far.