devtools::install_github("timelyportfolio/d3treeR")
## Skipping install of 'd3treeR' from a github remote, the SHA1 (ebb833db) has not changed since last install.
##   Use `force = TRUE` to force installation
#Required Packages
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.3     v purrr   0.3.4
## v tibble  3.1.0     v dplyr   1.0.4
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## Warning: package 'stringr' was built under R version 4.0.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(treemap)
library(d3treeR)
#Setup work directory
setwd("C:/Users/mivul/OneDrive/Desktop/Data 110/Datasets")
#Upload McDonald menu csv file
mcd <-read.csv("menu.csv")

how many meals can you eat at mcdonalds while maintiain under calories

Male age: 30 height: 5ft 9in weight: 168 actvity: 30 to 60 per day of moderate maintain 2600

Female age: 30 height: 5ft 4in weight: 144 actvity: less than 30 min/per day of moderate maintain 2000

2200

mcd %>%
  ggplot(aes(x = Calories, y = Category, fill = Category)) +
  geom_boxplot()+
  theme_classic()+
  theme(legend.position = "none")+
  ggtitle("Calorie Distribution of Food Categories")

# dataset
group <- c(rep("group-1",4),rep("group-2",2),rep("group-3",3))
subgroup <- paste("subgroup" , c(1,2,3,4,1,2,1,2,3), sep="-")
value <- c(13,5,22,12,11,7,3,1,23)
data <- data.frame(group,subgroup,value)
 
# basic treemap
p <- treemap(data,
            index=c("group","subgroup"),
            vSize="value",
            type="index",
            palette = "Set2",
            bg.labels=c("white"),
            align.labels=list(
              c("center", "center"), 
              c("right", "bottom")
            )  
          )            
## Warning in if (class(try(col2rgb(bg.labels), silent = TRUE)) == "try-error")
## stop("Invalid bg.labels"): the condition has length > 1 and only the first
## element will be used

# make it interactive ("rootname" becomes the title of the plot):
inter <- d3tree2( p ,  rootname = "General" )