55 lines
1.6 KiB
R
55 lines
1.6 KiB
R
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="<b>Sex in dataset</b>")
|
|
|
|
|
|
siha%>%
|
|
hchart(type = "pie", hcaes(x=sex, y = Probability, color = Probability), name='Probability') %>%
|
|
hc_title(text="<b>Sex if heart attack</b>")
|
|
|
|
|
|
|
|
|
|
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="<b>Probability of heart attack for sex and age group</b>")
|
|
|
|
|
|
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, '<br> Interval:', chol),
|
|
xaxis=list(categoryorder='total descending')) %>%
|
|
layout(title = 'Chol/probability',
|
|
xaxis = list(title = "Probability"),
|
|
yaxis = list(title = "Cholesterol"))
|
|
|