Sorting Month in the Highchater Graph X Axis

Plotting a bar graph using the Highchart in R

hchart( data, "column", hcaes(x = Month, y = Count, group = Name))

Have already tried using factoring the Month variable. But that did not help.

Did you make an ordered factor, like this:

library(ggplot2)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
df <- data.frame(Month = c("Jan", "Apr", "Jul", "Oct"), Value = 1:4)
ggplot(df, aes(Month, Value)) + geom_point()


df <- df %>% mutate(Month = factor(Month, levels = c("Jan", "Apr", "Jul", "Oct"),
                                      ordered = TRUE))
ggplot(df, aes(Month, Value)) + geom_point()

Created on 2019-05-22 by the reprex package (v0.2.1)

Tried the "Ordered" parameter still alphabetically sorted.

Since the obvious solution has failed, please post a Reproducible Example (Reprex) so we can work with specific code.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.