Displaying 20 results from an estimated 129 matches for "set_string_elt".
2013 Jun 27
3
Read a text file into R with .Call()
Hi,
I want to read a text file into R with .Call().
So I define some NEW_CHARACTER() to store the chracters read and use SET_STRING_ELT to fill the elements.
e.g.
PROTECT(qNames = NEW_CHARACTER(10000));
char *foo; // This foo holds the string I want.
while(foo = readLine(FN)){
SET_STRING_ELT(qNames, i, mkChar(foo)));
}
In this way, I can get the desired character from qNames. The only problem is that "mkChar" will mak...
2003 Sep 05
1
Problem with S4 slots in C code (PR#4073)
...= allocVector(VECSXP, 5));
PROTECT(d1 = allocVector(INTSXP, 1));
INTEGER(d1)[0] = 1;
SET_VECTOR_ELT(dimnames, 0, d1);
PROTECT(d2 = allocVector(INTSXP, 1));
INTEGER(d2)[0] = 2000;
SET_VECTOR_ELT(dimnames, 1, d2);
PROTECT(d3 = allocVector(STRSXP, 1));
SET_STRING_ELT(d3, 0, mkChar("combined"));
SET_VECTOR_ELT(dimnames, 2, d3);
PROTECT(d4 = allocVector(STRSXP, 1));
SET_STRING_ELT(d4, 0, mkChar("all"));
SET_VECTOR_ELT(dimnames, 3, d4);
PROTECT(d5 = allocVector(STRSXP, 1));
SET_STRING_ELT(d5, 0, mkChar("al...
2006 Nov 17
1
Manipulating R lists in C
...ACT=========
SEXP typeStr, volumeStr, priceStr, typeValStr;
SEXP priceList;
// create main list of vectors (unspecific items )
PROTECT( priceList = allocVector( VECSXP, 3 ) );
// for each item create a label and attach value
PROTECT( typeValStr = allocVector( STRSXP, 1 ) );
SET_STRING_ELT( typeValStr, 0,
mkChar( getPriceDataTypeAsString( p.getData().getType() ).c_str() ) );
SET_STRING_ELT( priceList, 0, typeValStr) ;
SEXP priceSXP;
PROTECT( priceSXP = allocVector( REALSXP, 1) );
REAL(priceSXP)[0] = p.getData().getPrice();
SET_VECTOR_ELT( priceList, 1, priceSXP);...
2023 Jan 31
1
Sys.getenv(): Error in substring(x, m + 1L) : invalid multibyte string at '<ff>' if an environment variable contains \xFF
...========================================
--- src/main/sysutils.c (revision 83731)
+++ src/main/sysutils.c (working copy)
@@ -393,8 +393,16 @@
char **e;
for (i = 0, e = environ; *e != NULL; i++, e++);
PROTECT(ans = allocVector(STRSXP, i));
- for (i = 0, e = environ; *e != NULL; i++, e++)
- SET_STRING_ELT(ans, i, mkChar(*e));
+ for (i = 0, e = environ; *e != NULL; i++, e++) {
+ cetype_t enc = known_to_be_latin1 ? CE_LATIN1 :
+ known_to_be_utf8 ? CE_UTF8 :
+ CE_NATIVE;
+ if (
+ (utf8locale && !utf8Valid(*e))
+ || (mbcslocale && !mbcsValid(*e))
+...
2009 Oct 01
1
Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character' & 'getEncChar' must be called on a CHARSXP
...wo elements
|__ Character
|__ Named List of 6 elements (characters and numerics)
This works,
sip <- lapply(h,function(r) r[[2]][['sip']])
but I wish to unlist this
sip <- unlist(lapply(h,function(r) r[[2]][['sip']]))
and get the following error:
Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'list'
Debugging to find which:
i<-1
sip <- unlist(lapply(h,function(r) {
i<<-i+1 #debug messages
cat(i,"------------------>","\n"); print( r[[2]] ) #debug message
r[[2]][['sip']]
}))
[1]Error in print.de...
2018 May 14
3
Rd parser throws error for user macros invoked with empty argument
Bug or feature?
I get the following error from parse_Rd() when a user Rd macro (including system ones) is invoked with empty argument {},
eg \mymacro{}:
Error in tools::parse_Rd(fn) :
Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'NULL'
A full example is further below with the system macro \CRANpkg{}. In this example it doesn't make sense to use empty argument but the error is not specific to this particular macro.
------
Georgi Boshnakov
Create an Rd file containing syste...
2014 Jun 26
1
using 2D array of SEXP for creating dataframe
...] ={99,89,12};
char *listnames[2] = {"int","string"};
int i,j;
//=============================
PROTECT(df = allocVector(VECSXP,2));
*PROTECT(valueVector[0] = allocVector(REALSXP,3));*
*PROTECT(valueVector[1] = allocVector(VECSXP,3));*
PROTECT(lsnm = allocVector(STRSXP,2));
SET_STRING_ELT(lsnm,0,mkChar("int"));
SET_STRING_ELT(lsnm,1,mkChar("string"));
SEXP rawvec,headr;
unsigned char str[24]="abcdef";
for ( i = 0 ; i < 3; i++ ) {
*SET_STRING_ELT(valueVector[1],i,mkChar(ab[i]));*
*REAL(valueVector[0])[i] = sn[i];*
}
It works , data frame is being...
2014 Mar 06
1
Create dataframe in C from table and return to R
...] = {"aa","vv","gy"};
int sn[3] ={99,89,12};
char *listnames[2] = {"int","string"};
int i;
PROTECT(df = allocVector(VECSXP,2));
PROTECT(dfint = allocVector(INTSXP,3));
PROTECT(dfStr = allocVector(STRSXP,3));
PROTECT(lsnm = allocVector(STRSXP,2));
SET_STRING_ELT(lsnm,0,mkChar("int"));
SET_STRING_ELT(lsnm,1,mkChar("string"));
for ( i = 0 ; i < 3; i++ ) {
SET_STRING_ELT(dfStr,i,mkChar(ab[i]));
INTEGER(dfint)[i] = sn[i];
}
SET_VECTOR_ELT(df,0,dfint);
SET_VECTOR_ELT(df,1,dfStr);
setAttrib(df,R_NamesSymbol,lsnm);
//PROTECT(dfm=LCONS(dfm,...
2008 Apr 25
2
Bug in R 2.7 for over long lines (crasher+proposed fix!) (PR#11281)
...is --> char *LongLine =3D (char *) malloc(nc);
> if(!LongLine)
> error(_("unable to allocate space for source line %
d"), xxlineno);
> strncpy(LongLine, (char *)p0, nc);
> bug --> LongLine[nc] =3D '\0';
> SET_STRING_ELT(source, lines++,
> mkChar2((char *)LongLine));
> free(LongLine);
>=20
> note that LongLine is only nc chars long, so the LongLine[nc]=3D'\0'
might
> be an out of bounds write. the fix would be to do
>=20
> =EF=BB=BF char *Lo...
2004 Jun 14
5
mkChar can be interrupted
...nclude <R.h>
SEXP foo0(const SEXP nSexp) {
int i, n;
SEXP resSexp;
if (!isInteger(nSexp))
error("wrong arg type\n");
n = asInteger(nSexp);
resSexp = PROTECT(allocVector(STRSXP, n));
Rprintf("!!!time to interrup!!!\n");
for (i=0; i<n; ++i) {
SET_STRING_ELT(resSexp, i, mkChar("foo"));
}
Rprintf("end mkChar\n");
UNPROTECT(1);
return R_NilValue;
}
# invoke 'foo0' and give it an argument large enough to let you type
Ctrl-C
# double the argument if you see "end mkChar" and do it again :-)
> x <-...
2018 May 25
2
Rd parser throws error for user macros invoked with empty argument
...h empty argument
Thanks for the report and the examples - and they do not have to be that
verbose, it is enough to just define and use a command, e.g.
cat("\\newcommand{\\mac1}{MAC1:#1}\\mac1{}", file=f)
rd <- tools::parse_Rd(f)
Whenever you get an error message like "Value of SET_STRING_ELT() must
be a 'CHARSXP' not a 'NULL'", there is a bug (at least the error message
should be relevant/informative).
I am testing a patch that will allow empty arguments to macros (they
will expand to an empty string, like in LaTeX).
Best
Tomas
On 05/14/2018 11:23 PM, Georgi...
2015 Dec 07
2
inconsistency in POSIXlt
The documentation for the POSIXlt class states '"POSIXlt" objects will
often have an attribute "tzone", a character vector of length 3 giving the
time zone name from the TZ environment variable and the names of the base
time zone and the alternate (daylight-saving) time zone. Sometimes this may
just be of length one, giving the time zone
2010 Jun 19
1
more powerful iconv
...outbuf = cbuff.data; outb = cbuff.bufsize - 1;
@@ -622,7 +623,7 @@
goto next_char;
}
- if(res != -1 && inb == 0) {
+ if(res != -1 && inb == 0 && !isRawx) {
cetype_t ienc = CE_NATIVE;
nout = cbuff.bufsize - 1 - outb;
@@ -632,7 +633,12 @@
}
SET_STRING_ELT(ans, i, mkCharLenCE(cbuff.data, nout, ienc));
}
- else SET_STRING_ELT(ans, i, NA_STRING);
+ else if(!isRawx) SET_STRING_ELT(ans, i, NA_STRING);
+ else {
+ nout = cbuff.bufsize - 1 - outb;
+ ans = allocVector(RAWSXP, nout);
+ memcpy(RAW(ans), cbuff.data, nout);
+ }
}
Ric...
2004 Mar 17
1
best methods for strings and structures?
..._plot_radius;
double min_prism_dbh;
double baf;
unsigned long max_sample_size;
unsigned long use_precip_in_hg;
};
with an internal function and I'm building the return object using the
following code:
PROTECT( ret_val = allocVector( VECSXP, 13 ) );
SET_STRING_ELT( ret_val, 0, mkChar( cfg_rec.coeffs_filename) );
SET_STRING_ELT( ret_val, 1, mkChar( cfg_rec.species_filename) );
SET_VECTOR_ELT( ret_val, 2, ScalarInteger( cfg_rec.use_random_error ) );
SET_VECTOR_ELT( ret_val, 3, ScalarInteger( cfg_rec.random_seed ) );
SET_VECTOR_ELT( ret_val, 4, Scal...
2019 Nov 01
3
Getting error in rbindlist
...rbindlist(use.names=TRUE,fill = TRUE)
+ ) %>% rbindlist(use.names=TRUE,fill = TRUE)
+ ) %>% rbindlist(use.names=TRUE,fill = TRUE, idcol = "Item")
*Error message:*
Error in rbindlist(., use.names = TRUE, fill = TRUE, idcol = "Item") :
attempt to set index 8424/8424 in SET_STRING_ELT
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
I am not understanding what is in SET_STRING_ELT which it is trying to
throw an error.
Please help me
*Regards,*
*Anshul Saravgi*
Consulting
m: 7757030307
<https://www.o9solutions.com/>
AI powered solutions...
2001 Dec 03
0
Segfault in foreign:read.xport (PR#1192)
...ad.xport from package foreign (version 0.4-7). The culprit
seems to be these lines in xport_read in SASxport.c:
590 } else {
591 c = strchr(tmpchar, ' ');
592 *c = '\0';
593 SET_STRING_ELT(VECTOR_ELT(data, k), j,
594 (c == tmpchar) ?
R_BlankString :
595 mkChar(tmpchar));
596 }
(gdb) print tmpchar
$1 = 0xb63674 "0502"
(gdb) print c
$2 = 0x0
According to the solaris...
2008 Apr 25
1
Bug in R 2.7 for over long lines
...e { /* over-long line */
fixthis --> char *LongLine = (char *) malloc(nc);
if(!LongLine)
error(_("unable to allocate space for source line %d"), xxlineno);
strncpy(LongLine, (char *)p0, nc);
bug --> LongLine[nc] = '\0';
SET_STRING_ELT(source, lines++,
mkChar2((char *)LongLine));
free(LongLine);
note that LongLine is only nc chars long, so the LongLine[nc]='\0' might
be an out of bounds write. the fix would be to do
? char *LongLine = (char *) malloc(nc+1);
in line 3034
Pl...
2008 Mar 17
1
Inconsistency in gsub in R.2.6.2 (PR#10978)
Hi,
May this be an oversight?
R version 2.6.2 Patched (2008-03-13 r44783)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
...
> x <- "ab?"
> Encoding(x)
[1] "latin1"
> Encoding(gsub("?","", x))
[1] "unknown"
> Encoding(gsub("?","", x, perl = TRUE))
[1] "latin1"
2000 Aug 09
2
GenGC changes
...tyle like.
VECTOR(dimnames)[0] = getAttrib(x, R_NamesSymbol);
but that is no longer allowed. The functions `VECTOR_ELT' and
`SET_VECTOR_ELT' must now be used to access and set elements of a
generic vector. There are analogous functions `STRING_ELT' and
`SET_STRING_ELT' for character vectors.
To convert existing code, use the following replacements.
original replacement
`foo = VECTOR(bar)[i]' `foo = VECTOR_ELT(bar, i)'
`VECTOR(foo)[j] = bar' `SET_VECTOR_ELT(foo, j, bar)'...
2016 Oct 24
3
typo or stale info in qr man
man for `qr` says that the function uses LINPACK's DQRDC, while it in
fact uses DQRDC2.
```
The QR decomposition of the matrix as computed by LINPACK or LAPACK.
The components in the returned value correspond directly to the values
returned by DQRDC/DGEQP3/ZGEQP3
```