Displaying 20 results from an estimated 28 matches for "na_string".
Did you mean:
pa_string
2010 Jun 19
1
more powerful iconv
...f(!isString(CADDR(args)) || length(CADDR(args)) != 1)
error(_("invalid '%s' argument"), "to");
if(!isString(CADDDR(args)) || length(CADDDR(args)) != 1)
error(_("invalid '%s' argument"), "sub");
- if(STRING_ELT(CADDDR(args), 0) == NA_STRING) sub = NULL;
+ if(STRING_ELT(CADDDR(args), 0) == NA_STRING || isRawx) sub = NULL;
else sub = translateChar(STRING_ELT(CADDDR(args), 0));
mark = asLogical(CAD4R(args));
if(mark == NA_LOGICAL)
@@ -584,7 +585,7 @@
PROTECT(ans = duplicate(x));
R_AllocStringBuffer(0, &cbuff); /* 0 -> d...
2016 May 12
3
Suggestion: mkString(NULL) should be NA
...suddenly NULL if libcurl was built with some unusual
configuration. These problems are hard to catch and I don't see any
benefit of segfaulting for such edge cases.
Some packages use a macro like this to protect against such problems:
#define make_string(x) x ? Rf_mkString(x) : ScalarString(NA_STRING)
But I think it would make sense if this was the default behavior in
Rf_mkString and Rf_mkChar.
2010 Feb 22
1
shash in unique.c
...string it points to?
In other words could the SEXP pointer be cast to unsigned int and the usual
scatter be called on that as if it were integer?
shash would look like a slightly modified version of ihash like this :
static int shash(SEXP x, int indx, HashData *d)
{
if (STRING_ELT(x,indx) == NA_STRING) return 0;
return scatter((unsigned int) (STRING_ELT(x,indx), d);
}
rather than its current form which appears to hash the string it points to :
static int shash(SEXP x, int indx, HashData *d)
{
unsigned int k;
const char *p;
if(d->useUTF8)
p = translateCharUTF8(STRING_ELT(x,...
2015 Jun 13
2
Lack of protection bug in current R release candidate
The current R release candidate has a lack of protect bug (of very
long standing) with respect to the R_print.na_string and
R_print.na_string_noquote fields of the static R_print structure
declared in Print.h. This shows up very occassionally as incorrect
output from the following lines in reg-tests-2.R:
x <- c("a", NA, "b")
factor(x)
factor(x, exclude="")
The solution (klud...
2007 Sep 13
1
chartr better
...ee(trs_old_ptr); Free(trs_new_ptr);
+ qsort(xtable, xtable_cnt, sizeof(xtable_t),
+ (int(*)(const void *, const void *))xtable_comp);
+
n = LENGTH(x);
PROTECT(y = allocVector(STRSXP, n));
for(i = 0; i < n; i++) {
if (STRING_ELT(x,i) == NA_STRING)
SET_STRING_ELT(y, i, NA_STRING);
else {
+ xtable_t *tbl;
xi = translateChar(STRING_ELT(x, i));
nc = mbstowcs(NULL, xi, 0);
if(nc < 0)
error(_("invalid input multibyte string...
2015 Jun 15
0
Lack of protection bug in current R release candidate
...ford Neal <radford at cs.toronto.edu>
>>>>> on Sat, 13 Jun 2015 17:24:04 -0400 writes:
> The current R release candidate has a lack of protect bug
> (of very long standing)
[ but not really reported, right ? ]
> with respect to the
> R_print.na_string and R_print.na_string_noquote fields of
> the static R_print structure declared in Print.h. This
> shows up very occassionally as incorrect output from the
> following lines in reg-tests-2.R:
> x <- c("a", NA, "b")
> factor(x)
> fac...
2019 Jan 21
0
orderVector1 (sort.c): Tiny improvement concerning nalast
...**
switch (TYPEOF(key)) {
case LGLSXP:
case INTSXP:
! for (i = 0; i < n; i++) isna[i] = (ix[i] == NA_INTEGER);
! break;
case REALSXP:
! for (i = 0; i < n; i++) isna[i] = ISNAN(x[i]);
! break;
case STRSXP:
! for (i = 0; i < n; i++) isna[i] = (sx[i] == NA_STRING);
! break;
case CPLXSXP:
! for (i = 0; i < n; i++) isna[i] = ISNAN(cx[i].r) || ISNAN(cx[i].i);
! break;
default:
! UNIMPLEMENTED_TYPE("orderVector1", key);
}
! for (i = 0; i < n; i++) numna += isna[i];
if(numna)
switch (TYPEOF(key)) {
--- 1...
2011 Jan 25
1
NA printing
...ntially by
M[is.na(M)] <- "-" but this interferes with the pleasing
column alignment for numerical matrices.
How do I make R print "-" instead of "NA" for NA entries in a numeric
matrix, without altering the vertical alignment? Is there such a command
as
options(NA_string = "-")
available?
best wishes
Robin Hankin
2019 Jan 11
2
strtoi output of empty string inconsistent across platforms
...irable. The relevant
> utility function in R's source (<R>/src/main/character.c)
> is
> static int strtoi(SEXP s, int base) { long int res; char
> *endp;
> /* strtol might return extreme values on error */
> errno = 0;
> if(s == NA_STRING) return(NA_INTEGER); res =
> strtol(CHAR(s), &endp, base); /* ASCII */ if(errno ||
> *endp != '\0') res = NA_INTEGER; if(res > INT_MAX || res <
> INT_MIN) res = NA_INTEGER; return (int) res; }
> and so it clearly is a platform-inconsistency in the...
2007 Jul 23
1
CHAR(STRING_ELT( - OK but CHAR(asChar(STRING_ELT( - not, why?
Any idea why CHAR(asChar(STRING_ELT( produces NA whereas
CHAR(STRING_ELT( gets a pointer to a string? It's generally expected
that STRING_ELT should already be a character, but why the coercion does
not work? Here is a simple example (consistent over R2.5.1-R2.6 rev
42284, I didn't check earlier versions, but it used to be different in
2.4):
install.packages("inline")
2016 May 24
2
Suggestion: mkString(NULL) should be NA
...jeroen.ooms at stat.ucla.edu>
> wrote:
> > I would like to propose that Rf_mkString(NULL) and Rf_mkChar(NULL)
> > return NA rather than segfault.
>
> An example implementation: https://git.io/vroxm
>
> With this patch, mkChar(NULL), mkCharCE(NULL, ce) would return
> NA_STRING rather than segfault at strlen(NULL). This automatically
> fixes mkString(NULL) as well which wraps mkChar (See Rinlinedfuns.h).
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Gabr...
2019 Jan 11
2
strtoi output of empty string inconsistent across platforms
Identified as root cause of a bug in data.table:
https://github.com/Rdatatable/data.table/issues/3267
On my machine, strtoi("", base = 2L) produces NA_integer_ (which seems
consistent with ?strtoi: "Values which cannot be interpreted as integers or
would overflow are returned as NA_integer_").
But on all the other machines I've seen, 0L is returned. This seems to be
2002 Aug 13
2
Misalignment of <NA> in rownames (PR#1905)
...src/main/printutils.c. MatrixRowLabel and
MatrixColumnLabel (same file) rely on Rstrlen to count the characters in each
label, but Rstrlen doesn't understand NA's. Here's a patch, to be applied
between lines 242 ("int len;") and 243 ("len = 0;"):
if (s == CHAR(NA_STRING))
return quote ? R_print.na_width : R_print.na_width_noquote;
which solves the problem:
R-patched> x
A B C D
a 1 4 7 10
<NA> 2 5 8 11
c 3 6 9 12
-----------------------------------------------------------------------------
An NA in the colnames has similar misalignmen...
2016 May 24
2
Suggestion: mkString(NULL) should be NA
...g should arguably
generate "". i don't think the fact that there is another way to get "" is
a particularly large problem.
On the other hand, and in support of your position it came up as Michael
Lawrence and I were talking about this that asChar from utils.c will give
you NA_STRING when you give it R_NilValue. That is a coercion though,
whereas arguably mkString is not. That said, consistency would probably be
good.
~G
--
Gabriel Becker, PhD
Associate Scientist (Bioinformatics)
Genentech Research
[[alternative HTML version deleted]]
2010 Sep 08
0
Correction to vec-subset speed patch
...LEX(x)[ii];
- }
- else {
- COMPLEX(result)[i].r = NA_REAL;
- COMPLEX(result)[i].i = NA_REAL;
- }
- break;
- case STRSXP:
- if (0 <= ii && ii < nx && ii != NA_INTEGER)
- SET_STRING_ELT(result, i, STRING_ELT(x, ii));
- else
- SET_STRING_ELT(result, i, NA_STRING);
- break;
- case VECSXP:
- case EXPRSXP:
- if (0 <= ii && ii < nx && ii != NA_INTEGER)
- SET_VECTOR_ELT(result, i, VECTOR_ELT(x, ii));
- else
- SET_VECTOR_ELT(result, i, R_NilValue);
- break;
- case LISTSXP:
+ switch (mode) {
+ case LGLSXP:
+ fo...
2009 Jan 30
2
Problem installing RMySQL ("S4R.h:40:17: error: S.h: No such file or directory"?)
...eclared (first use in this function)
RS-DBI.c:1231: error: 'STRSXP' undeclared (first use in this function)
RS-DBI.c:1233: warning: implicit declaration of function 'CHAR'
RS-DBI.c:1233: warning: implicit declaration of function 'CHARACTER_POINTER'
RS-DBI.c:1233: error: 'NA_STRING' undeclared (first use in this function)
RS-DBI.c:1233: error: subscripted value is neither array nor pointer
RS-DBI.c: At top level:
RS-DBI.c:1238: error: expected declaration specifiers or '...' before
'SEXPTYPE'
RS-DBI.c: In function 'RS_is_na':
RS-DBI.c:1244: error:...
2009 May 23
2
as.numeric(levels(factor(x))) may be a decreasing sequence
...}
+ while (*(replace++) = *(p++)) {
+ ;
+ }
+ break;
+ }
+ }
+ return s;
+}
+
SEXP attribute_hidden StringFromReal(double x, int *warn)
{
int w, d, e;
formatReal(&x, 1, &w, &d, &e, 0);
if (ISNA(x)) return NA_STRING;
- else return mkChar(EncodeReal(x, w, d, e, OutDec));
+ else return mkChar(elim_trailing(EncodeReal(x, w, d, e, OutDec), OutDec));
}
SEXP attribute_hidden StringFromComplex(Rcomplex x, int *warn)
2019 Jan 11
0
strtoi output of empty string inconsistent across platforms
.../documentable?
The inconsistency is certainly undesirable.
The relevant utility function in R's source (<R>/src/main/character.c)
is
static int strtoi(SEXP s, int base)
{
long int res;
char *endp;
/* strtol might return extreme values on error */
errno = 0;
if(s == NA_STRING) return(NA_INTEGER);
res = strtol(CHAR(s), &endp, base); /* ASCII */
if(errno || *endp != '\0') res = NA_INTEGER;
if(res > INT_MAX || res < INT_MIN) res = NA_INTEGER;
return (int) res;
}
and so it clearly is a platform-inconsistency in the underlying C
library'...
2019 Jan 12
0
strtoi output of empty string inconsistent across platforms
...ction in R's source (<R>/src/main/character.c)
> > is
>
> > static int strtoi(SEXP s, int base) { long int res; char
> > *endp;
>
> > /* strtol might return extreme values on error */
> > errno = 0;
>
> > if(s == NA_STRING) return(NA_INTEGER); res =
> > strtol(CHAR(s), &endp, base); /* ASCII */ if(errno ||
> > *endp != '\0') res = NA_INTEGER; if(res > INT_MAX || res <
> > INT_MIN) res = NA_INTEGER; return (int) res; }
>
> > and so it clearly is a platform-i...
2012 Feb 26
2
Dealing with NAs in C
Hi.
I am currently converting a lot of R code to C in order to make it more
efficient. A lot of the data involves NAs. As the data is mainly integers >
0, I am just setting all NAs to 0 then sending it to the C code then
resetting them to NAs again after the C program is done, to be compatible
with the rest of the R code.
Is there a more efficient way to deal with NAs in C? I have used