Skip to content

Commit

Permalink
v6.3 : fix bad sorting of break values in parcoords plots (fix #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
RCura committed May 20, 2019
1 parent f282625 commit b213dbc
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src_plots/plotly_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ create_dims <- function(df, index){
returnList[["tickvals"]] <- values %>% sort() %>% unique() %>% signif(., digits = 2)
}
} else {
# if (!is.null(values) && all(as.character(as.numeric(values)) == values)){
# MyFactors <- values %>% as.numeric() %>% sort() %>% as.character() %>% unique() %>% as_factor()
# } else {
MyFactors <- values %>% as.character() %>% unique() %>% sort() %>% as_factor()
# }
MyFactors <- values %>% as.character() %>% unique() %>% sort() %>% as_factor()
if (!is.null(values) && all(as.character(as.numeric(levels(MyFactors))) == levels(MyFactors))){
MyFactorsLvls <- levels(MyFactors) %>% as.numeric() %>% sort() %>% as.character()
MyFactors <- fct_relevel(MyFactors, MyFactorsLvls)
}
returnList[["values"]] <- values %>% factor(levels = levels(MyFactors)) %>% as.numeric()
returnList[["tickvals"]] <- MyFactors %>% as.numeric() %>% unique()
returnList[["tickvals"]] <- MyFactors %>% as.numeric() %>% sort()
returnList[["ticktext"]] <- levels(MyFactors)
}
if (label == "seed"){
Expand All @@ -28,6 +28,10 @@ create_dims <- function(df, index){

char_to_num <- function(x){
MyFactors <- as.character(x) %>% unique() %>% sort() %>% as.factor()
if (all(as.character(as.numeric(levels(MyFactors))) == levels(MyFactors))){
MyFactorsLvls <- levels(MyFactors) %>% as.numeric() %>% sort() %>% as.character()
MyFactors <- fct_relevel(MyFactors, MyFactorsLvls)
}
values <- x %>% factor(levels = levels(MyFactors)) %>% as.numeric()
return(values)
}
Expand Down

0 comments on commit b213dbc

Please sign in to comment.