# Shiny Module to show scatter plot using highcharter scatterUI<-function(id){ ns<-NS(id) tagList( highchartOutput(ns("scatterPlot")) ) } # Server scatterServer<-function(id,df){ moduleServer(id,function(input,output,session){ output$scatterPlot<-renderHighchart({ summ.dat<-df |> group_by(Cluster) |> mutate( self=sum(Self.Purchase1)+sum(Self.Purchase2)+sum(Self.Purchase3), other=sum(Other.Purchase1)+sum(Other.Purchase2)+sum(Other.Purchase3) ) hchart(summ.dat, type = "scatter", hcaes(x = self, y = other, color = factor(Cluster))) |> hc_plotOptions( scatter = list(jitter = list(x = 10000000, y = 10000000)) ) |> hc_title(text = "K-means Clustering Visualization") |> hc_xAxis(title = list(text = "Self")) |> hc_yAxis(title = list(text = "Other")) |> # add Cluster as hover info hc_tooltip(pointFormat = "Cluster: {point.Cluster}") }) } ) }