Simple examples found on the web to understand how to do a sunburst plot.

1st Example

https://gist.github.com/kerryrodden/7090426#file-visit-sequences-csv

library(sunburstR)
## Warning: package 'sunburstR' was built under R version 3.5.3
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.5.3
## -- Attaching packages -------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.1.0       v purrr   0.3.2  
## v tibble  2.1.1       v dplyr   0.8.0.1
## v tidyr   0.8.0       v stringr 1.3.1  
## v readr   1.3.1       v forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 3.5.2
## Warning: package 'tibble' was built under R version 3.5.3
## Warning: package 'readr' was built under R version 3.5.3
## Warning: package 'purrr' was built under R version 3.5.3
## Warning: package 'dplyr' was built under R version 3.5.3
## Warning: package 'forcats' was built under R version 3.5.3
## -- Conflicts ----------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
sequences <- read.csv(system.file("examples/visit-sequences.csv",package="sunburstR"),header = FALSE,stringsAsFactors = FALSE)[1:100,]

print(head(sequences))
##                                                V1    V2
## 1 account-account-account-account-account-account 22781
## 2     account-account-account-account-account-end  3311
## 3    account-account-account-account-account-home   906
## 4   account-account-account-account-account-other  1156
## 5 account-account-account-account-account-product  5969
## 6  account-account-account-account-account-search   692
sunburst(sequences)
Legend
# explore some of the arguments

sunburst(sequences,
         count = TRUE,
         percent = TRUE,
         colors = c("#111d4a","#ffcf99","#92140c","#1e1e24", "#fff8f0", "#0b7a750"),
         height = "800px",
         width = "100%"
         # explanation would put the % and count out
         #,explanation = "function(d){return d.data.name}"
         )
Legend
sunburst(sequences
         # apply sort order to the legends
         ,legendOrder = unique(unlist(strsplit(sequences[,1],"-")))
         # just provide the name in the explanation in the center
         ,explanation = "function(d){return d.data.name}")
Legend

2nd Example

https://github.com/timelyportfolio/sunburstR/blob/master/inst/examples/example_calendar.R

# calendar sunburst example

df <- data.frame(
  date = seq.Date(
    as.Date('2014-01-01'),
    as.Date('2016-12-31'),
    by = "days"
  ),
  stringsAsFactors = FALSE
)

df$year = format(df$date, "%Y")
df$quarter = paste0("Q", ceiling(as.numeric(format(df$date,"%m"))/3))
df$month = format(df$date, "%b")
df$path = paste(df$year, df$quarter, df$month, sep="-")
df$count = rep(1, nrow(df))

print(head(data.frame(xtabs(count~path,df))))
##          path Freq
## 1 2014-Q1-Feb   28
## 2 2014-Q1-Jan   31
## 3 2014-Q1-Mar   31
## 4 2014-Q2-Apr   30
## 5 2014-Q2-Jun   30
## 6 2014-Q2-May   31
sunburst(
  data.frame(xtabs(count~path,df)),
  # added a degree of difficulty by providing
  #  not easily sortable names
  sortFunction = htmlwidgets::JS(
    "
    function(a,b){
    abb = {
    2014:-7,
    2015:-6,
    2016:-5,
    Q1:-4,
    Q2:-3,
    Q3:-2,
    Q4:-1,
    Jan:1,
    Feb:2,
    Mar:3,
    Apr:4,
    May:5,
    Jun:6,
    Jul:7,
    Aug:8,
    Sep:9,
    Oct:10,
    Nov:11,
    Dec:12
    }
    return abb[a.data.name] - abb[b.data.name];
    }
    "
  )
  )
Legend