Displaying 20 results from an estimated 1000 matches similar to: "ScalarLong?"
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
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
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
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")
>
2019 Feb 27
2
Intermittent crashes with inset `[<-` command
Valgrind (without gctorture) reports memory misuse:
% R --debugger=valgrind --debugger-args="--leak-check=full --num-callers=18"
...
> x <- 1:200000
> y <- rep(letters[1:5], length(x) / 5L)
> for (i in 1:1000) {
+ # x[y == 'a'] <- x[y == 'b']
+ x <- `[<-`(x, y == 'a', x[y == 'b'])
+ cat(i, '')
+ }
1 2 3 4 5 6 7 8 9 10
2004 Mar 17
1
best methods for strings and structures?
I'm trying to generate an R interface for a library that's commonly used and
I'm currently writing wrapper functions for file i/o and return an object
(list?) that contains the elements of the C structure. For example, reading
a file that contains:
struct CONFIG_RECORD
{
char coeffs_filename[256];
char species_filename[256];
unsigned long
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
2016 Oct 03
0
On implementing zero-overhead code reuse
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 with path". That allows me to find code I reuse
in standard locations.
I don't know why R does not
2006 May 23
1
protect
I have a few simple questions about the usage of PROTECT, more
specifically how careful one needs to be. Simple yes/no answers are
fine.
Most of the uses I have seen do protection when memory is allocated.
But what if one just want to assign a value of another function to a
variable. Say eg. that foo is a function that returns a SEXP. Would
the following code be fine?
SEXP bar;
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
0
On implementing zero-overhead code reuse
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")
foo$bar(1,2,3)
rather than
import("foo")
bar(1,2,3)
(Just a personal
2018 Jun 28
1
Null pointer dereference in Rf_isVector()
Hello,
After some fuzz testing I found a problem with Rf_isVector() function in
R 3.5.0.
Platform: Ubuntu 16.04
Compiler: Clang-4.0 (from Ubuntu's repository) + ASAN
Crashing R code:
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 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",
2018 Mar 29
2
Possible `substr` bug in UTF-8 Corner Case
I think there is a memory bug in `substr` that is triggered by a UTF-8 corner case: an incomplete UTF-8 byte sequence at the end of a string.? With a valgrind level 2 instrumented build of R-devel I get:
> string <- "abc\xEE"??? # \xEE indicates the start of a 3 byte UTF-8 sequence
> Encoding(string) <- "UTF-8"
> substr(string, 1, 10)
==15375== Invalid read of
2018 Nov 15
2
STRING_IS_SORTED claims as.character(1:100) is sorted
If I have loaded the C code:
SEXP altrep_STRING_IS_SORTED(SEXP x)
{
return ScalarInteger(STRING_IS_SORTED(x));
}
and defined the function:
issort <- function(x) .Call("altrep_STRING_IS_SORTED",x)
I am seeing the following results in R 3.5.1/Linux:
> issort(LETTERS)
[1] NA
> issort(as.character(1:100)) ## should return NA
[1] 1
>
2014 Oct 31
3
ScalarLogical and setAttrib
Is it expected that attributes set on a LGLSXP created by
ScalarLogical will apply to all future objects created by
ScalarLogical as well? For example: the 'test1' function below returns
FALSE and 'test2' returns FALSE with an attribute:
library(inline)
test1 <- cfunction(body = 'return ScalarLogical(0);')
test2 <- cfunction(body = '
SEXP success =