Highcharter R Package Essentials for Easy Interactive Graphs

Highchart Interactive Funnel Chart in R

This article describes how to create an interactive funnel chart in R using the highcharter R package.

Funnel charts are often used to represent stages in a sale process and show the amount of potential revenue for each stage. A funnel chart displays values as progressively decreasing proportions amounting to 100 percent in total.



Contents:

Loading required R packages

# Load required R packages
library(dplyr)
library(highcharter) 
# Set highcharter options
options(highcharter.theme = hc_theme_smpl(tooltip = list(valueDecimals = 2)))

Data preparation

df <- data.frame(
        x = c(0, 1, 2, 3, 4),
        y = c(10, 19.4, 21.1, 14.4, 6.4),
        name = as.factor(c("grape", "olive", "guava", "nut", "pear"))
) %>%
  arrange(-y)
df
##   x    y  name
## 1 2 21.1 guava
## 2 1 19.4 olive
## 3 3 14.4   nut
## 4 0 10.0 grape
## 5 4  6.4  pear

Create a funnel chart

hc <- df %>%
  hchart(
    "funnel", hcaes(x = name, y = y),
    name = "Fruit consumption"
    )
hc



Version: Français

Highchart Interactive Pie Chart and Alternatives in R (Prev Lesson)
(Next Lesson) Highchart Interactive Pyramid Chart in R
Back to Highcharter R Package Essentials for Easy Interactive Graphs

No Comments

Give a comment

Want to post an issue with R? If yes, please make sure you have read this: How to Include Reproducible R Script Examples in Datanovia Comments