How to Create A Funnel Chart In R

Written by finnstats | Published 2021/06/23
Tech Story Tags: datascience | statistics | r | charts | highcharter | data | data-analysis | software-development

TLDR A funnel chart is mainly used for demonstrates the flow of users through a business or sales process. The number of users at each stage of the process are represented from the funnel’s width as it narrows. This chart takes its name from its shape, which starts from a broad head and ends in a small neck. In this article we are going to describe how to create an interactive funnel chart in R, that is interactive. The chart is high level visualization before going to deeper and deeper investigations.via the TL;DR App

Funnel Chart in R, A funnel chart is mainly used for demonstrates the flow of users through a business or sales process. This chart takes its name from its shape, which starts from a broad head and ends in a small neck.
The number of users at each stage of the process are represented from the funnel’s width as it narrows.
Based on funnel chart can understand easily there are any significant drop offs and can make decisions accordingly. Note the drop reasons we need to analyze it separately to get the clarity.
So basically funnel charts are high level visualization before going to deeper and deeper investigations.
In this article we are going to describe how to create funnel chart in R, that is interactive.
If you are not installed highcharter package install the same based on below command.

Funnel Chart in R

 Install.packages(“highcharter”)
Load required R packages, here we are using dplyr and highcharter.
library(dplyr)
library(highcharter) 
Once you loaded the package then need to set the high charter options.
options(highcharter.theme = hc_theme_smpl(tooltip = list(valueDecimals = 2)))
Let’s create a data frame for plotting
df <- data.frame(
  x = c(0, 1, 2, 3, 4),
  y = c(975, 779, 584, 390, 200),
  name = as.factor(c("Leads", "Sales Call", "Follow Up", "Conversion", "Sale"))
) %>%
  arrange(-y)
Here we are talking about sales process in different stages like, leads, sales call, follow up, conversion and sales.
df
x   y       name
1 0 975      Leads
2 1 779 Sales Call
3 2 584  Follow Up
4 3 390 Conversion
5 4 200       Sale
Let’s create an interactive funnel chart in R
hc <- df %>%
  hchart(
    "funnel", hcaes(x = name, y = y),
    name = "Sales Conversions"
  )
hc
Note displayed normal 'png' image, If you want to see the magics of interactive let's plot it.

Written by finnstats | Enjoys working with data...
Published by HackerNoon on 2021/06/23