library(highcharter) library(tidyr) library(plotly) library(dplyr) basedf<-read.csv("dev/matma_bayes/heart.csv", header = TRUE) siha<-read.csv('dev/matma_bayes/sex_if_heart_attack.csv') df2<-read.csv('dev/matma_bayes/age_sex_heart_attack.csv') chol<-read.csv('dev/matma_bayes/chol_sex_heart_attack.csv') basedf$sex[basedf$sex==1]<-'Man' basedf$sex[basedf$sex==0]<-'Woman' df2$sex[df2$sex==1]<-'Man' df2$sex[df2$sex==0]<-'Woman' chol$sex[chol$sex==1]<-'Man' chol$sex[chol$sex==0]<-'Woman' df2$x<-paste(df2$sex,df2$age) basedf%>% count(sex)%>% arrange(n)%>% hchart(type = "pie", hcaes(x=sex, y = n, color = n), name="Quantity") %>% hc_title(text="Sex in dataset") siha%>% hchart(type = "pie", hcaes(x=sex, y = Probability, color = Probability), name='Probability') %>% hc_title(text="Sex if heart attack") df2%>% hchart('column', hcaes(x=x, y=heart.attack, group=age))%>% hc_plotOptions(column = list(stacking = "normal"))%>% hc_xAxis(title=list(text='Age'))%>% hc_yAxis(title=list(text='Probability'))%>% hc_legend(enabled=F)%>% hc_title(text="Probability of heart attack for sex and age group") chol %>% drop_na(heart.attack)%>% plot_ly(x = ~heart.attack, y = ~sex, type = 'bar', orientation = 'h', color = ~chol, colors ='Spectral', hoverinfo = 'text', text = ~paste('Probability:', heart.attack, '
Interval:', chol), xaxis=list(categoryorder='total descending')) %>% layout(title = 'Chol/probability', xaxis = list(title = "Probability"), yaxis = list(title = "Cholesterol"))