Displaying 5 results from an estimated 5 matches for "childresult".
2018 May 08
2
unlist errors on a nested list of empty lists
...GICAL. But then it does C-style logical testing on the
results. I think to C NA_LOGICAL counts as true, so at the next level
up we get the wrong answer.
A fix would be to rewrite it like this:
static Rboolean islistfactor(SEXP X)
{
int i, n = length(X);
Rboolean result = NA_LOGICAL, childresult;
switch(TYPEOF(X)) {
case VECSXP:
case EXPRSXP:
for(i = 0; i < LENGTH(X); i++) {
childresult = islistfactor(VECTOR_ELT(X, i));
if(childresult == FALSE) return FALSE;
else if(childresult == TRUE) result = TRUE;
}
ret...
2018 May 09
2
unlist errors on a nested list of empty lists
...? I think to C NA_LOGICAL counts as true, so at the next level
> up we get the wrong answer.
>
> A fix would be to rewrite it like this:
>
> static Rboolean islistfactor(SEXP X)
> {
> ? ? ?int i, n = length(X);
> ? ? ?Rboolean result = NA_LOGICAL, childresult;
> ? ? ?switch(TYPEOF(X)) {
> ? ? ?case VECSXP:
> ? ? ?case EXPRSXP:
> ? ? ? ? ?for(i = 0; i < LENGTH(X); i++) {
> ? ? ? ? ? ? ?childresult = islistfactor(VECTOR_ELT(X, i));
> ? ? ? ? ? ? ?if(childresult == FALSE) return FALSE;
> ? ? ? ? ?...
2018 May 08
0
unlist errors on a nested list of empty lists
...testing on the
> results. I think to C NA_LOGICAL counts as true, so at the next level
> up we get the wrong answer.
>
> A fix would be to rewrite it like this:
>
> static Rboolean islistfactor(SEXP X)
> {
> int i, n = length(X);
> Rboolean result = NA_LOGICAL, childresult;
> switch(TYPEOF(X)) {
> case VECSXP:
> case EXPRSXP:
> for(i = 0; i < LENGTH(X); i++) {
> childresult = islistfactor(VECTOR_ELT(X, i));
> if(childresult == FALSE) return FALSE;
> else if(childresult == TRUE) res...
2018 May 08
2
unlist errors on a nested list of empty lists
Reproducible example:
x <- list(list(list(), list()))
unlist(x)
*> Error in as.character.factor(x) : malformed factor*
What should happen:
unlist(x)
> NULL
R.version
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 5.0
year 2018
month 04
day
2018 May 09
0
unlist errors on a nested list of empty lists
...o at the next
> level
> > up we get the wrong answer.
> >
> > A fix would be to rewrite it like this:
> >
> > static Rboolean islistfactor(SEXP X)
> > {
> > int i, n = length(X);
> > Rboolean result = NA_LOGICAL, childresult;
> > switch(TYPEOF(X)) {
> > case VECSXP:
> > case EXPRSXP:
> > for(i = 0; i < LENGTH(X); i++) {
> > childresult = islistfactor(VECTOR_ELT(X, i));
> > if(childresult == FALSE) retu...