similar to: Qs: The list of arguments, wrapping functions...

Displaying 20 results from an estimated 6000 matches similar to: "Qs: The list of arguments, wrapping functions..."

2016 Oct 03
4
On implementing zero-overhead code reuse
Hi Frederick, I described what I meant in the post I sent to R-help (https://stat.ethz.ch/pipermail/r-help/2016-September/442174.html), but in brief, by "zero overhead" I mean that the only thing needed for library code to be accessible to client code is for it to be located in designed directory. No additional meta-files, packaging/compiling, etc. are required. Best, G. On Sun, Oct
2016 Oct 02
5
On implementing zero-overhead code reuse
I'm looking for a way to approximate the "zero-overhead" model of code reuse available in languages like Python, Perl, etc. I've described this idea in more detail, and the motivation for this question in an earlier post to R-help (https://stat.ethz.ch/pipermail/r-help/2016-September/442174.html). (One of the responses I got advised that I post my question here instead.) The
2009 May 22
2
how to insert NULLs in lists?
I'm an experienced programmer, but learning R is making me lose the little hair I have left... > list(NULL) [[1]] NULL > length(list(NULL)) [1] 1 > x <- list() > x[[1]] <- NULL > x list() > length(x) [1] 0 >From the above experiment, it is clear that, although one can create a one-element list consisting of a NULL element, one can't get the same result by
2016 Oct 03
3
On implementing zero-overhead code reuse
On Mon, Oct 3, 2016 at 10:18 AM, <frederik at ofb.net> wrote: > Hi Kynn, > > Thanks for expanding. > > I wrote a function like yours when I first started using R. It's > basically the same up to your "new.env()" line, I don't do anything > with environmentns. I just called my function "mysource" and it's > essentially a "source
2009 May 20
10
How to google for R stuff?
Hi! I'm new to R programming, though I've been programming in other languages for years. One thing I find most frustrating about R is how difficult it is to use Google (or any other search tool) to look for answers to my R-related questions. With languages with even slightly more distinctive names like Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the language
2009 Jun 06
1
Qs on calling R from C
Consider the following simple C program: /*** hello_r.c ***/ #include <Rinternals.h> SEXP hello() { return mkString("Hello, world!\n"); } int main(void) { SEXP x = hello(); return x == NULL; /* i.e. 0 on success */ } This program segfaults: % myR/bin/R CMD LINK gcc -I./R-2.9.0/src/include -L./myR/lib64/R/lib -lR hello_r.c -o hello_r > /dev/null % hello_r zsh:
2007 Oct 25
3
Deparsing part of a list argument
Here's a simple example of the type of function I'm trying to write, where the first argument is a list of functions: myfun <- function(funlist, vec){ tmp <- lapply(funlist, function(x)do.call(x, args = list(vec))) names(tmp) <- names(funlist) tmp } > myfun(list("Summation" = sum, prod, "Absolute value" = abs), c(1, 4, 6, 7)) $Summation [1]
2004 Apr 05
3
Evaluation of functionals
Suppose I have f1 <- function(x) x f2 <- function(x) x^2 funlist <- list(f1,f2) Then I would like to evaluate funlist such that when x is 10 I should get a list with 10 and 100. A naive way of doint this is myf <- funlist[[1]] do.call(paste(quote(myf)), list(x=10)) myf <- funlist[[2]] do.call(paste(quote(myf)), list(x=10)) - but there has to be much
2009 Jun 25
1
R data inspection under gdb?
Hi, everyone. I'm trying to debug an R-module, written in C, and I'm using gdb for this. How can I print "standard" R objects from within C code? BTW, I'm familiar with the advice to use R_PV given in Writing R Extensions, but it's not working for me. E.g., I get (gdb) p R_PV(x) $1 = void and yet (gdb) p *x $2 = {sxpinfo = {type = 16, obj = 0, named = 0, gp = 0,
2016 Oct 03
2
On implementing zero-overhead code reuse
On 10/03/2016 01:51 PM, Kynn Jones wrote: > Thank you all for your comments and suggestions. > > @Frederik, my reason for mucking with environments is that I want to > minimize the number of names that import adds to my current > environment. For instance, if module foo defines a function bar, I > want my client code to look like this: > > import("foo") >
2010 Jan 27
1
returning a list of functions
Hi interested readers, I have a function that creates several functions within a loop and I would like them to be returned for further use as follows: Main.Function(df,...){ # df is a multivariate data funcList<-list(NULL) for (i in 1:ncol(df)){ temp<-logspline(df[,i],...) # logspline density estimate funcList[[i]]<-function(x){expression(temp,x)} } return(funcList) } I have tried
2005 Nov 02
2
Anything like associative arrays in R?
Let me preface my question by stressing that I am much less interested in the answer than in learning a way I could have *found the answer myself*. (As helpful as the participants in this list are, I have far too many R-related questions to resolve by posting here, and as I've written before, in my experience the R documentation has not been very helpful, but I remain hopeful that I may have
2023 Jun 27
0
[PATCH] fs: ocfs: fix potential deadlock on &qs->qs_lock
As &qs->qs_lock is also acquired by the timer o2net_idle_timer() which executes under softirq context, code executing under process context should disable irq before acquiring the lock, otherwise deadlock could happen if the process context hold the lock then preempt by the timer. Possible deadlock scenario: o2quo_make_decision (workqueue) -> spin_lock(&qs->qs_lock);
2023 Jun 27
0
[PATCH] fs: ocfs: fix potential deadlock on &qs->qs_lock
As &qs->qs_lock is also acquired by the timer o2net_idle_timer() which executes under softirq context, code executing under process context should disable irq before acquiring the lock, otherwise deadlock could happen if the process context hold the lock then preempt by the timer. Possible deadlock scenario: o2quo_make_decision (workqueue) -> spin_lock(&qs->qs_lock);
2016 May 20
2
identical on closures
I'm confused by this: > identical(function() {}, function() {}) [1] FALSE Yet, after loading the Matrix package (which redefines det), the following is checked (in library.checkConflicts): > identical(get("det", baseenv()), get("det", asNamespace("Matrix")), ignore.environment=T) [1] TRUE I've looked at the code in identical.c and for closures it
2009 Jun 13
1
conditional dependencies & loading
Hi! I'm working on a package that must convert data to and from JSON. For this, it can use either the rjson package, or preferably, the faster RJSONIO package. I have two related questions about this. First, how can I specify that the package depends on *either* RJSONIO *or* rjson? (I.e. both are not required.) Second, what's the best-practice R idiom for such conditional loading?
2009 Jun 12
1
Fast JSON <-> R converter?
Is there a *fast* converter between JSON and R? I'm aware of the rjson package, but it is implemented in R, and it is too slow for my purposes. TIA! kynn [[alternative HTML version deleted]]
2009 Jun 02
1
How to generate R objects in C?
I'm in the process of coding a parser (in C) to generate R entities (vectors, lists, etc.) from a text description (different from R). The basic parser works, and now I need to tell it how to create R entities. I need to be able to create character vectors (for unicode strings), integers, floats, unnamed lists, named lists, boolean values, and NA. With the exception of the two types of lists
2009 Jun 12
1
Issues converting from JSON to R
When converting from JSON to R it seems logical that a JSON array would correspond to an "unnamed" R list, while a JSON object would correspond to a "named" R list. E.g. JSON: [1, 3.1415927, "foo", false, null] => R: list(1, 3.1415927, "foo", FALSE, NA); and JSON { "int": 1, "float": 3.1415927, "string": "foo",
2015 Apr 04
0
nutdrv_qx hangs after send: QS
On Apr 4, 2015, at 7:19 PM, Richard Flint <richard.flint at gmail.com> wrote: > More extensive debugging by running the driver sudo ./nutdrv_qx -u root -a MY_UPS -DDDDDD indicates the driver works normally then will randomly stop working at stop "send: QS". The debug logs show values successfully retrieved repeatedly until something like: > .... > Quick update... >