Matematyka_Bayes/charts.R

37 lines
1.2 KiB
R
Raw Normal View History

2021-05-31 22:09:09 +02:00
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')
basedf$sex[basedf$sex==1]<-'Man'
basedf$sex[basedf$sex==0]<-'Woman'
df2$sex[df2$sex==1]<-'Man'
df2$sex[df2$sex==0]<-'Woman'
df2$x<-paste(df2$sex,df2$age)
df2$comb<-
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>")
basedf%>%
group_by(sex, chol)%>%
count()%>%
hchart('area', hcaes(x='chol', y='n', group='sex'))%>%
hc_xAxis(title=list(text='Cholesterol'))%>%
hc_yAxis(title=list(text='Quantity'))%>%
hc_title(text="<b>Number of terrorists attacks in each year by region</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'))%>%
2021-05-31 22:15:53 +02:00
hc_legend(enabled=F)%>%
hc_title(text="<b>Probability of heart attack for sex and age group</b>")