Displaying 20 results from an estimated 31 matches for "rf_mkchar".
2016 May 12
3
Suggestion: mkString(NULL) should be NA
I would like to propose that Rf_mkString(NULL) and Rf_mkChar(NULL)
return NA rather than segfault.
Case: the mkString() and mkChar() functions are convenient to wrap
strings returned by e.g. external C libraries into an R vector.
However sometimes a library returns NULL instead of a string when the
result is unavailable. In some C libraries this can happen...
2011 Oct 13
1
how to return a matrix of strings from c to R ?
...n_rics,s->n_fields));
int i,j;
for (i=0; i < s->n_rics; i++)
{
for (j=0; j < s->n_fields; j++)
{
std::string text = s->data[j][i];
result[j][i] = R_alloc( text.length(), sizeof(char));
//strcpy(result[j][i], text.c_str());
SET_STRING_ELT(result[j][i],0,Rf_mkChar(text.c_str()));
}
}
// memcpy(result,s->data.ref(),s->n_fields*s->n_rics*sizeof(200));
UNPROTECT(1);
return result;
</code>
Can someone please make me understand this usecase and how to resolve it?
thanks,
Alok
--
View this message in context: http://r.789695.n4.nabble...
2010 May 06
1
R on kdeedu-svn library problem
...$SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:223: undefined
reference to `Rf_allocVector'
$SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:223: undefined
reference to `Rf_protect'
$SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:224: undefined
reference to `Rf_mkChar'
$SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:224: undefined
reference to `SET_STRING_ELT'
$SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:226: undefined
reference to `R_NilValue'
$SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:226: undefined
referenc...
2010 Feb 20
1
how to create a SEXP which could be accessed in embedded R
Hi all,
I am not familiar with writing R extensions. In a C program, I want to create a SEXP and access it in embedded R. How to let the embedded engine know there's a new vector? For example, after creating a SEXP, parsing 'ls()' in embedded R and then evaluating, STRSXP returned will contain the name of the SEXP. Any help would be appreciated.
Regards,
Spiral
[[alternative HTML
2016 May 25
2
Suggestion: mkString(NULL) should be NA
On Wed, May 25, 2016 at 12:31 PM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
> Better than segfaulting, yes, but really agree with Bill (and
> Gabe), also for Rf_mkChar(NULL):
> I think both functions should give an error in such a case
> rather than returning NA_character_
>
> It is an accident of some kind if they got NULL, no?
Not necessarily. A char* of NULL can be a string which is not
initiated or simply unavailable due to configuration.
The ex...
2013 Oct 16
1
Parallel R expression evaluations
...ot found
Error: argument to 'findVar' is not an environment
I am using the following code snippet for initializing R, parsing and
evaluation of R expression
// For initialization
int res= Rf_initEmbeddedR(R_argc, (char**)R_argv);
// For parsing and evaluation
SEXP cmd1= Rf_mkChar(rscript);
SEXP cmdSexp, cmdexpr, sresult = R_NilValue;
ParseStatus status;
R_len_t i=0;
PROTECT(cmdSexp = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(cmdSexp, 0, cmd1);
// parsing vector for R expressions
cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue));
if (status !=...
2016 May 24
2
Suggestion: mkString(NULL) should be NA
Shouldn't Rf_mkString(NULL) return (the c-level equivalent of) character()
rather than the NA_character_? An empty string and NULL aren't the same. It
seems reasonable for Rf_mkChar to give NA_character_ though.
~G
On Tue, May 24, 2016 at 8:42 AM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu>
wrote:
> On Thu, May 12, 2016 at 1:20 PM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu>
> wrote:
> > I would like to propose that Rf_mkString(NULL) and Rf_mkChar(NULL...
2019 Aug 02
4
Infrequent but steady NULL-pointer caused segfault in as.POSIXlt.POSIXct (R 3.4.4)
...= "%H%M")
7: format(Sys.time(), format = "%H%M")
? ?
I looked into the dumped core with gdb, and found something very strange:
gdb /usr/lib64/R/bin/exec/R ~/core.30387
(gdb) bt 5
#0 0x00007f1dca844ff1 in __strlen_sse2_pminub () from /lib64/libc.so.6
#1 0x00007f1dcb20e8f9 in Rf_mkChar (name=0x0) at envir.c:3725
#2 0x00007f1dcb1dc225 in do_asPOSIXlt (call=<optimized out>,
op=<optimized out>, args=<optimized out>,
env=<optimized out>) at datetime.c:705
#3 0x00007f1dcb22197f in bcEval (body=body at entry=0x4064b28,
rho=rho at entry=0xc449d38, useCache=...
2016 May 24
2
Suggestion: mkString(NULL) should be NA
On Tue, May 24, 2016 at 9:30 AM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu>
wrote:
> On Tue, May 24, 2016 at 5:59 PM, Gabriel Becker <gmbecker at ucdavis.edu>
> wrote:
> > Shouldn't Rf_mkString(NULL) return (the c-level equivalent of)
> character()
> > rather than the NA_character_?
>
> No. It should still be safe to assume that mkString() always returns
2005 Mar 14
2
Install the RMySQL
...cast
RS-MySQL.c: In function `RS_MySQL_getException':
RS-MySQL.c:789: `MYSQL' undeclared (first use in this
function)
RS-MySQL.c:789: `my_connection' undeclared (first use in
this function)
RS-MySQL.c:809: parse error before ')' token
RS-MySQL.c:811: warning: passing arg 1 of `Rf_mkChar' makes
pointer from integer without a cast
RS-MySQL.c: In function `RS_MySQL_closeResultSet':
RS-MySQL.c:822: `MYSQL_RES' undeclared (first use in this
function)
RS-MySQL.c:822: `my_result' undeclared (first use in this
function)
RS-MySQL.c:827: parse error before ')' tok...
2003 Oct 31
1
R-1.8.0 + IBM VisualAge/C for AIX compiler
...11-224 WARNING: Duplicate symbol: Rf_warning
ld: 0711-224 WARNING: Duplicate symbol: .Rf_lengthgets
ld: 0711-224 WARNING: Duplicate symbol: Rf_lengthgets
ld: 0711-224 WARNING: Duplicate symbol: .R_Reprotect
ld: 0711-224 WARNING: Duplicate symbol: R_Reprotect
ld: 0711-224 WARNING: Duplicate symbol: .Rf_mkChar
ld: 0711-224 WARNING: Duplicate symbol: Rf_mkChar
ld: 0711-224 WARNING: Duplicate symbol: .SET_STRING_ELT
ld: 0711-224 WARNING: Duplicate symbol: SET_STRING_ELT
ld: 0711-224 WARNING: Duplicate symbol: .Rf_isNull
ld: 0711-224 WARNING: Duplicate symbol: Rf_isNull
[...]
ld: 0711-224 WARNING: Duplicate...
2009 Sep 03
1
Running an expression 1MN times using embedded R
...eUInt(stle);
// fwrite(&len_rev,sizeof(uint32_t),1,stderr);
// fwrite(status,stle,1,stderr);
}
SEXP rexpress(const char* cmd)
{
SEXP cmdSexp, cmdexpr, ans = R_NilValue;
int i,Rerr;
ParseStatus status;
PROTECT(cmdSexp = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(cmdSexp, 0, Rf_mkChar(cmd));
cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue));
if (status != PARSE_OK) {
UNPROTECT(2);
return(R_NilValue);
}
for(i = 0; i < Rf_length(cmdexpr); i++)
ans = R_tryEval(VECTOR_ELT(cmdexpr, i),NULL,&Rerr);
UNPROTECT(2);
return(ans);...
2019 Aug 04
1
Infrequent but steady NULL-pointer caused segfault in as.POSIXlt.POSIXct (R 3.4.4)
...; ? ?
> >
> > I looked into the dumped core with gdb, and found something very strange:
> >
> > gdb /usr/lib64/R/bin/exec/R ~/core.30387
> > (gdb) bt 5
> > #0 0x00007f1dca844ff1 in __strlen_sse2_pminub () from /lib64/libc.so.6
> > #1 0x00007f1dcb20e8f9 in Rf_mkChar (name=0x0) at envir.c:3725
> > #2 0x00007f1dcb1dc225 in do_asPOSIXlt (call=<optimized out>,
> > op=<optimized out>, args=<optimized out>,
> > env=<optimized out>) at datetime.c:705
> > #3 0x00007f1dcb22197f in bcEval (body=body at entry=0x4064b...
2016 May 25
0
Suggestion: mkString(NULL) should be NA
On Wed, May 25, 2016 at 4:23 AM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu>
wrote:
> On Wed, May 25, 2016 at 12:31 PM, Martin Maechler
> <maechler at stat.math.ethz.ch> wrote:
> > Better than segfaulting, yes, but really agree with Bill (and
> > Gabe), also for Rf_mkChar(NULL):
> > I think both functions should give an error in such a case
> > rather than returning NA_character_
> >
> > It is an accident of some kind if they got NULL, no?
>
> Not necessarily. A char* of NULL can be a string which is not
> initiated or simply unavail...
2024 May 28
2
Segfault when parsing UTF-8 text with srcrefs
Hi all,
When I run the following code, R segfaults:
text <- "?"
srcfile <- srcfilecopy("test.r", text)
parse(textConnection(text), srcfile = srcfile)
It doesn't segfault if text is ASCII, or it's not wrapped in
textConnection, or srcfile isn't set.
Hadley
--
http://hadley.nz
[[alternative HTML version deleted]]
2002 May 01
0
Problems with embedded R for v1.5.0
...lted during startup in exactly the same place,
apparently while trying to load the ctest package. Recompiling the packages
doesn't seem to have any effect on this outcome.
Here's the first few lines of a gdb backtrace:
#0 0xff132df8 in strlen () from /usr/lib/libc.so.1
#1 0xfe612bcc in Rf_mkChar (name=0x12a46d9 <Address 0x12a46d9 out of
bounds>)
at dstruct.c:102
#2 0xfe5f5f40 in do_readDCF (call=0x0, op=0xffffffff, args=0x950ce0,
env=0x954370) at dcf.c:109
#3 0xfe64d010 in do_internal (call=0xfe7694f4, op=0x12b9c4, args=0x950ce0,
env=0x9503b8) at names.c:1020
(I can...
2014 Mar 07
0
Repost: (apologies for HTML post) A question about multiple(?) out of order ReleaseObject
...r not have to worry about that because i intend to balance it later.
Regards
Saptarshi
There was a follow up in a subsequent email
Hello,
However, I do need some sort of protection.
(pseudo code)
SEXP a = Rf_allocVector(STRSXP,....)
protect a
for i = 1 to length of vector
SET_STRING_ELT(a,i, Rf_mkChar(...))
end
unprotect a
return a
I _need _that protect because in the for loop i also call some R functions
and need the object 'a' to be protected.
However, as I pointed out,
1. I replaced protect by PreserveObject
2. remove the unprotect word
I can guarantee, that some time later Release...
2014 Mar 07
0
Many apologies: last post: A question about multiple(?) out of order ReleaseObject
...r not have to worry about that because i intend to balance it later.
Regards
Saptarshi
There was a follow up in a subsequent email
Hello,
However, I do need some sort of protection.
(pseudo code)
SEXP a = Rf_allocVector(STRSXP,....)
protect a
for i = 1 to length of vector
SET_STRING_ELT(a,i, Rf_mkChar(...))
end
unprotect a
return a
I _need _that protect because in the for loop i also call some R functions
and need the object 'a' to be protected.
However, as I pointed out,
1. I replaced protect by PreserveObject
2. remove the unprotect word
I can guarantee, that some time later Release...
2002 Jan 02
1
Building R-1.4 on Tru64
..._data.o slot.o -L/usr/local/lib
/usr/ucb/ld:
Warning: Unresolved:
TYPEOF
Rf_error
Rf_protect
Rf_substitute
Rf_unprotect
Rf_duplicate
Rf_VectorToPairList
R_NilValue
Rf_NewEnvironment
R_set_standardGeneric_ptr
R_GlobalEnv
R_set_quick_method_check
Rf_install
Rf_allocVector
LOGICAL
R_PreserveObject
Rf_mkChar
SET_STRING_ELT
Rf_findVar
R_UnboundValue
VECTOR_ELT
R_NamesSymbol
Rf_getAttrib
Rf_length
STRING_ELT
R_CHAR
R_do_slot
Rf_asChar
PRINTNAME
Rf_isNull
CAR
CDR
R_data_class
Rf_isFunction
Rf_findFun
SETCAR
Rf_eval
INTEGER
CLOENV
Rf_findVarInFrame
Rf_isSymbol
ENCLOS
SYMVALUE
Rf_asLogical
R_MissingArg
Rf_i...
2016 May 25
0
Suggestion: mkString(NULL) should be NA
...ou get NA.
>>
>> Rf_mkString(NULL) <--> NA
>> Rf_mkString("") <--> ""
>>
>> There is no ambiguity, and much better than segfaulting.
Better than segfaulting, yes, but really agree with Bill (and
Gabe), also for Rf_mkChar(NULL):
I think both functions should give an error in such a case
rather than returning NA_character_
It is an accident of some kind if they got NULL, no?
--
Martin Maechler,
ETH Zurich
> Well, better than segfaulting is not really relevant here. No one is
> arguing that it shou...