hchart(Breakfast.ing_times,"column",hcaes(x ="times",y = "n"))%>%
  hc_plotOptions(column= list(dataLabels = list(enabled =TRUE)))%>%
  hc_title(text= "Breakfast frequency table", align='center')
hchart(Lunch.ing_times,"column",hcaes(x ="times",y = "n"))%>%
  hc_plotOptions(column= list(dataLabels = list(enabled =TRUE)))%>%
  hc_title(text= "Lunch frequency table", align='center')
hchart(Dinner.ing_times,"column",hcaes(x ="times",y = "n"))%>%
  hc_plotOptions(column= list(dataLabels = list(enabled =TRUE)))%>%
  hc_title(text= "Dinner frequency table", align='center')
hchart(Dessert.ing_times,"column",hcaes(x ="times",y = "n"))%>%
  hc_plotOptions(column= list(dataLabels = list(enabled =TRUE)))%>%
  hc_title(text= "Dessert frequency table", align='center')
All <- merge(Breakfast.ing_times,Lunch.ing_times,by="times",all=T)
All <- merge(All,Dinner.ing_times,by="times",all=T)             
All <- merge(All,Dessert.ing_times,by="times",all=T) 
All[is.na(All)] <- 0
colnames(All) <- c("times","n1","n2","n3","n4")

highchart() %>%
  hc_xAxis(categories = All$times,title = list(text = "times"))%>%
  hc_add_series(name = "Breakfast", data = All$n1,type = "column") %>%
  hc_add_series(name = "Lunch", data = All$n2,type = "column") %>%
  hc_add_series(name = "Dinner", data = All$n3,type = "column") %>%
  hc_add_series(name = "Dessert", data = All$n4,type = "column") %>%
  hc_title(text= "times table", align='center')
#https://bookdown.org/xiangyun/r4ds/dv-highcharter.html
Classical_MDS_highchart <- function(n,MDS_ingredients,CATEGORY,color){

  mds.non.r <- t(MDS_ingredients) %>%
    dist() %>%          
    cmdscale(k=n) %>%
    as_tibble()
  
  if(n==2){
    colnames(mds.non.r) <- c("x.1", "x.2")
  }else if(n==3){
    colnames(mds.non.r) <- c("x.1", "x.2", "x.3")
    # as.matrix
    mds.non.r_1 <- as.matrix(mds.non.r[1])
    mds.non.r_2 <- as.matrix(mds.non.r[2])
    mds.non.r_3 <- as.matrix(mds.non.r[3])
    mds.non.r <- cbind(mds.non.r_1,mds.non.r_2,mds.non.r_3)}
  
  # Plot MDS
  if(n==2){
    mds.non.r=as.data.frame(mutate(mds.non.r,ingredient=colnames(MDS_ingredients)))
    mds.non.r=as.data.frame(mutate(mds.non.r,Category=CATEGORY))
    hchart(mds.non.r,"point",hcaes(x ="x.1",y = "x.2",group = Category), color = color)%>%
      hc_tooltip(useHTML = TRUE,pointFormat = "{point.ingredient}")%>%
      hc_title(text= "Euclidean Dist MDS", align='center',style = list( fontSize = "30px"))
    }}
Classical_MDS_highchart(2,Breakfast.ing.,"Breakfast","#FF44AA")
Classical_MDS_highchart(2,Lunch.ing.,"Lunch","#EE7700")
Classical_MDS_highchart(2,Dinner.ing.,"Dinner","#00AA55")
Classical_MDS_highchart(2,Dessert.ing.,"Dessert","#9900FF")
Classical_MDS_highchart(2,Breakfast.ing.from.allrecipes.com,"allrecipes.com","#FF44AA")
Classical_MDS_highchart(2,Breakfast.ing.from.ALDI,"ALDI","#FF44AA")
Classical_MDS_highchart(2,Breakfast.ing.from.cookingchanneltv,"cookingchanneltv","#FF44AA")
Classical_MDS_highchart(2,Breakfast.ing.from.jamieoliver,"jamieoliver","#FF44AA")
Classical_MDS_highchart(2,Breakfast.ing.from.pinchOfYum,"pinchOfYum","#FF44AA")
Classical_MDS_highchart(2,Lunch.ing.from.ALDI,"ALDI","#EE7700")
Classical_MDS_highchart(2,Lunch.ing.from.cookingchanneltv,"cookingchanneltv","#EE7700")
Classical_MDS_highchart(2,Lunch.ing.from.jamieoliver,"jamieoliver","#EE7700")
Classical_MDS_highchart(2,Lunch.ing.from.pinchOfYum,"pinchOfYum","#EE7700")
Classical_MDS_highchart(2,Dinner.ing.from.ALDI,"ALDI","#00AA55")
Classical_MDS_highchart(2,Dinner.ing.from.cookingchanneltv,"cookingchanneltv","#00AA55")
Classical_MDS_highchart(2,Dinner.ing.from.jamieoliver,"jamieoliver","#00AA55")
Classical_MDS_highchart(2,Dinner.ing.from.pinchOfYum,"pinchOfYum","#00AA55")
Classical_MDS_highchart(2,Dessert.ing.from.allrecipes.com,"allrecipes.com","#9900FF")
Classical_MDS_highchart(2,Dessert.ing.from.ALDI,"ALDI","#9900FF")
Classical_MDS_highchart(2,Dessert.ing.from.jamieoliver,"jamieoliver","#9900FF")
Classical_MDS_highchart(2,Dessert.ing.from.pinchOfYum,"pinchOfYum","#9900FF")