search for: isfactor

Displaying 8 results from an estimated 8 matches for "isfactor".

2018 May 08
2
unlist errors on a nested list of empty lists
...XP X) { int i, n = length(X); switch(TYPEOF(X)) { case VECSXP: case EXPRSXP: if(n == 0) return NA_LOGICAL; for(i = 0; i < LENGTH(X); i++) if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; return TRUE; break; } return isFactor(X); } One of those deeply nested lists is length 0, so at the lowest level it returns NA_LOGICAL. 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...
2018 May 09
2
unlist errors on a nested list of empty lists
...gt; ? ? ?case EXPRSXP: > ? ? ? ? ?if(n == 0) return NA_LOGICAL; > ? ? ? ? ?for(i = 0; i < LENGTH(X); i++) > ? ? ? ? ? ? ?if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; > ? ? ? ? ?return TRUE; > ? ? ? ? ?break; > ? ? ?} > ? ? ?return isFactor(X); > } > > One of those deeply nested lists is length 0, so at the lowest level it > returns NA_LOGICAL.? 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. &g...
2002 Mar 02
1
accessing factor levels from C
.... As I see, the factors are basically integers with attribute ,,levels''. But unfortunately I am not been able to read the levels information. I am using: SEXP variable, levels; ... variable = VECTOR_ELT( data_frame, j); switch( TYPEOF( variable)) { case INTSXP: if( isFactor( VECTOR_ELT( data_frame, j))) { fvalue = INTEGER( variable)[i]; levels = STR_PTR( GET_LEVELS( variable)); .... but the variable levels is not an array of strings as I expected. I am probably doing something in the wrong way but how would it be correct? Thanks in advance, Ott Toomet -.-...
2018 May 08
0
unlist errors on a nested list of empty lists
...ch(TYPEOF(X)) { > case VECSXP: > case EXPRSXP: > if(n == 0) return NA_LOGICAL; > for(i = 0; i < LENGTH(X); i++) > if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; > return TRUE; > break; > } > return isFactor(X); > } > > One of those deeply nested lists is length 0, so at the lowest level it > returns NA_LOGICAL. 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 b...
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
...t; if(n == 0) return NA_LOGICAL; > > for(i = 0; i < LENGTH(X); i++) > > if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; > > return TRUE; > > break; > > } > > return isFactor(X); > > } > > > > One of those deeply nested lists is length 0, so at the lowest level > it > > returns NA_LOGICAL. 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 >...
2006 Feb 13
2
?bug? strange factors produced by chron
Hallo all Please help me. I am lost and do not know what is the problem. I have a factor called kvartaly. > attributes(kvartaly) $levels [1] "1Q.04" "2Q.04" "3Q.04" "4Q.04" "1Q.05" "2Q.05" "3Q.05" "4Q.05" $class [1] "factor" > mode(kvartaly) [1] "numeric" > str(kvartaly) Factor w/ 8
2006 Jul 27
6
Any interest in "merge" and "by" implementations specifically for sorted data?
Hi Developers, I am looking for another new project to help me get more up to speed on R and to learn something outside of R internals. One recent R issue I have run into is finding a fast implementations of the equivalent to the following SAS code: /* MDPC is an integer sort key made from two integer columns */ MDPC = (MD * 100000) + PCO; /* sort the dataset by the key */ PROC SORT;