I noticed this unexpected behaviour when colouring a map. If you try to set an attribute as a vector of NAs, you get an error. If you have some character values and some NAs, there's no error/warning and result have changed NA values to "NA".
I'm assuming that there's a reason for this; I'd be interested to know what it is.
I think a warning, "NA values have been converted too character", would be useful and some detail in the documentation. I'm happy to do this next time I work on Racmacs (but might need a hand with the warning).
Edit: Perhaps the NA values should be converted to ""?
> library(Racmacs)
> packageVersion("Racmacs")
[1] ‘1.1.35’
> set.seed(850909)
> dat <- matrix(10*2^round(10*runif(100)), ncol=10)
> map <- make.acmap(dat)
Performing 100 optimizations
============================================================================================================
Optimization runs complete
Took 0.05 secs
>
> map_col <- rep(NA, 10)
> map_col[1:5] <- rainbow(5)
> map_col
[1] "#FF0000" "#CCFF00" "#00FF66" "#0066FF" "#CC00FF" NA NA NA NA NA
>
> agFill(map) <- map_col
> agFill(map)
[1] "#FF0000" "#CCFF00" "#00FF66" "#0066FF" "#CC00FF" "NA" "NA" "NA" "NA" "NA"
>
>
> srIDs(map) <- rep(NA,10)
Error: Input must be a character vector
>
> sr_id <- rep(NA,10)
> sr_id[1:5] <- paste0("S",1:5)
> srIDs(map) <- sr_id
> srIDs(map)
[1] "S1" "S2" "S3" "S4" "S5" "NA" "NA" "NA" "NA" "NA"
I noticed this unexpected behaviour when colouring a map. If you try to set an attribute as a vector of NAs, you get an error. If you have some character values and some NAs, there's no error/warning and result have changed
NA
values to"NA"
.I'm assuming that there's a reason for this; I'd be interested to know what it is.
I think a warning, "NA values have been converted too character", would be useful and some detail in the documentation. I'm happy to do this next time I work on Racmacs (but might need a hand with the warning).
Edit: Perhaps the NA values should be converted to ""?