[Rd] Thread-safe R functions

2020-09-13 Thread Jiefei Wang
Hi, I am curious about whether there exist thread-safe functions in `Rinternals.h`. I know that R is single-threaded designed, but for the simple and straightforward functions like `DATAPTR` and `INTEGER_GET_REGION`, are these functions safe to call in a multi-thread environment? Best, Jiefei

Re: [Rd] [External] Thread-safe R functions

2020-09-14 Thread Jiefei Wang
global lock you >> need to keep in mind that any function in the R API can signal an >> error and execute a longjmp, so you need to make sure you have set a >> top level context in your thread. >> >> Best, >> >> luke >> >> On Sun, 13

[Rd] Coercion function does not work for the ALTREP object

2020-10-07 Thread Jiefei Wang
Hi all, The coercion function defined for the ALTREP object will not be called by R when an assignment operation implicitly introduces coercion for a large ALTREP object. For example, If I create a vector of length 10, the ALTREP coercion function seems to work fine. ``` > x <- 1:10 > y <- wrap_a

Re: [Rd] Coercion function does not work for the ALTREP object

2020-10-07 Thread Jiefei Wang
Hi Gabriel, here is a simple package for reproducing the problem. https://github.com/Jiefei-Wang/testPkg Best, Jiefei On Thu, Oct 8, 2020 at 5:04 AM Gabriel Becker wrote: > Jiefei, > > Where does the code for your altrep class live? > > Thanks, > ~G > > On Wed, Oct 7

[Rd] Is there any way to check the class of an ALTREP?

2020-10-19 Thread Jiefei Wang
Hi all, I would like to determine if an ALTREP object is from my package, I see there is a function `ALTREP_CLASS` defined in RInternal.h but its return value is neither a `R_altrep_class_t` object nor an STRSXP representing a class name. I do not know how to correctly use it. Any suggestions? Th

Re: [Rd] Is there any way to check the class of an ALTREP?

2020-10-19 Thread Jiefei Wang
to the OP's own package :) I > > think Jiefei would like to know how one can "officially" determine if an > > arbitrary ALTERP object belongs to a class that he owns. > > > > Regards, > > Denes > > > > > > On 10/19/20 10:22 A

Re: [Rd] Is there any way to check the class of an ALTREP?

2020-10-19 Thread Jiefei Wang
is no such function in R to get the class of an ALTREP object for the SEXP struct is very compact and this less-important information might not be stored when an ALTREP object is created. Best, Jiefei On Mon, Oct 19, 2020 at 8:37 PM Jiefei Wang wrote: > Thank Denes for the clarification, glad t

[Rd] Something is wrong with the unserialize function

2020-10-29 Thread Jiefei Wang
Hi all, I am not able to export an ALTREP object when `gctorture` is on in the worker. The package simplemmap can be used to reproduce the problem. See the example below ``` ## Create a temporary file filePath <- tempfile() con <- file(filePath, "wrb") writeBin(rep(0.0,10),con) close(con) library

Re: [Rd] [External] Something is wrong with the unserialize function

2020-10-29 Thread Jiefei Wang
t" > >con <- file(filePath, "wrb") > >writeBin(rep(0.0,10),con) > >close(con) > > > >library(simplemmap) > >x <- mmap(filePath, "double") > >saveRDS(x, file = "x.Rds") > > > >##

[Rd] Two ALTREP questions

2020-11-21 Thread Jiefei Wang
Hello, I have two related ALTREP questions. It seems like there is no way to assign attributes to an ALTREP vector without using C++ code. To be more specifically, I want to make an ALTREP matrix, I have tried the following R code but none of them work. ``` .Internal(inspect(1:6)) .Internal(inspec

Re: [Rd] [External] Two ALTREP questions

2020-11-21 Thread Jiefei Wang
ttps://www.r-project.org/ Bugzilla sounds like a good place to start, I will send an email to acquire an account. Best, Jiefei On Sun, Nov 22, 2020 at 6:57 AM wrote: > On Sat, 21 Nov 2020, Jiefei Wang wrote: > > > Hello, > > > > I have two related ALTREP questions. It seems l

[Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Jiefei Wang
Hi all, I'm trying to get the field value of a reference object by the field name, but the dollar symbol behaves quite unusual. See example below *.foo <- setRefClass("foo",fields = list(a = "integer" ))x <- .foo$new(a=1L)## This is OKx$a## This is OK`$`(x, "a")## But

Re: [Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Jiefei Wang
n purpose as the above example works for both list and S4 system. Best, Jiefei On Sat, Mar 27, 2021 at 10:20 PM Duncan Murdoch wrote: > > On 27/03/2021 10:16 a.m., Jiefei Wang wrote: > > Hi all, > > > > I'm trying to get the field value of a reference object by

Re: [Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Jiefei Wang
before backticks could be used to make > symbol literals for symbols that included odd things like spaces and > dollar signs. > > -Bill > > On Sat, Mar 27, 2021 at 7:49 AM Jiefei Wang wrote: > > > > Thanks, Duncan. Below is the repost of my question in plain text

Re: [Rd] Possible ALTREP bug

2021-05-28 Thread Jiefei Wang
Hi Gabor, Calling back to an R function from the ALTREP function is not safe. There has been a heated discussion on why you should not do it and that the main reason that we do not have any R level ALTREP API. If you are interested in it you can find it from this issue: https://github.com/Biocondu

[Rd] User interrupts parallel excution. Why it works or why not?

2021-07-20 Thread Jiefei Wang
Hi all, I just notice this interesting problem a few days before, but I cannot find an answer for it. Say if you have a long-running job in a cluster made by the parallel package and you decide to stop the execution by pressing ctr + c in the terminal or the stop button in Rstudio for some reason.

Re: [Rd] User interrupts parallel excution. Why it works or why not?

2021-07-20 Thread Jiefei Wang
t; the onintrEx() function, etc. A good source on signal handling is e.g. > http://www.linusakesson.net/programming/tty/ > > Best > Tomas > > On 7/20/21 9:55 AM, Jiefei Wang wrote: > > Hi all, > > > > I just notice this interesting problem a few days before, bu

[Rd] How is the environment variable "R_USER" defined?

2021-11-22 Thread Jiefei Wang
Hi, I have a new win system and try to install R as usual. Somehow, the environment variable "R_LIBS_USER" is incorrectly pointed to a Onedrive folder. Since "R_LIBS_USER" depends on "R_USER", the root problem then becomes why "R_USER" is the path to the Onedrive. I did an exhausting search in the

Re: [Rd] How is the environment variable "R_USER" defined?

2021-11-22 Thread Jiefei Wang
uments linked to OneDrive (either by your choice > or by some administrator setting a group policy)? If so, ou could unlink it > using OneDrive's settings dialog. Or you could set R_USER to avoid using > ...\Documents. > > -Bill > > On Mon, Nov 22, 2021 at 8:47 A

[Rd] Great overhead for setTimeLimit?

2021-12-06 Thread Jiefei Wang
Hi all, >From the document of 'setTimeLimit', it states "Setting any limit has a small overhead – well under 1% on the systems measured.", but something is wrong with my benchmark code, enabling the time limit makes my benchmark 1x slower than the benchmark without the limit. Below is an example

[Rd] The enclosed environment does not work as expected

2022-04-02 Thread Jiefei Wang
Hi, It seems like the enclosed environment does not work well with the loop. Here is a simple example ``` FuncGenerator <- function(value){ function() message(value) } funcSets <- list() for(i in 1:2) funcSets[[i]] <- FuncGenerator(i) environment(funcSets[[1]])$value # [1] 2 environment(

[Rd] Strange Behavior in RNG

2024-08-16 Thread Jiefei Wang
Hi, I just observed a strange behavior in R. The rnorm function does not give me the numbers with a given length. I think it is somehow related to the internal representation of double-type numbers but I am not sure if this is supposed to happen. Below is a reproducible example ``` ## Create a li

Re: [Rd] Strange Behavior in RNG

2024-08-16 Thread Jiefei Wang
ction can tolerate a certain degree of errors. Maybe I have too much expectations for it... Best, Jiefei On Fri, Aug 16, 2024, 22:19 Rui Barradas wrote: > Às 01:45 de 17/08/2024, Jiefei Wang escreveu: > > Hi, > > > > I just observed a strange behavior in R. The rnorm functio