RobinHankin / permutations

https://robinhankin.github.io/permutations/
5 stars 3 forks source link

if a vector has names then as.word() does not work #1

Closed RobinHankin closed 2 years ago

RobinHankin commented 6 years ago
> a <- c(5,1:4)
> as.word(a)
[1] (15432)
> names(a) <- letters[1:5]
> a
a b c d e 
5 1 2 3 4 
> as.word(a)
Error in FUN(newX[, i], ...) : 
  invalid word: rows should be permutations of seq_len(ncol(w))
> 

the names should be silently set to NULL, as they can have no meaning in the package.

also:

> rbind(a)
  a b c d e
a 5 1 2 3 4
> word(rbind(a))
Error in FUN(newX[, i], ...) : 
  invalid word: rows should be permutations of seq_len(ncol(w))
> 

in both cases the error message is cryptic at best and misleading at worst.