TakeCareApp/app/klasyfikator.R

78 lines
2.4 KiB
R
Raw Normal View History

2021-01-16 02:13:21 +01:00
library(shiny)
library(magrittr)
library(ggplot2)
library(plotly)
library(DT)
# Define UI for application that draws a histogram
klasyui <- function(id){
ns <- NS(id)
fluidPage(
# Application title
titlePanel("Klasyfikator"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("slider1",
"Wiek pacjenta",
min = 1,
max = 100,
value = 1),
selectInput("select1",strong("Zaburzenia polykania"),choices = list("Nie"=0,"Tak"=1),selected=0),
2021-01-17 21:11:11 +01:00
selectInput("select2",strong("Bol przy polykaniu"),choices = list("Nie"=0,"Tak"=1),selected=0),
2021-01-16 02:13:21 +01:00
selectInput("select3",strong("Kaszel"),choices = list("Nie"=0,"Tak"=1),selected=0),
selectInput("select4",strong("Dusznosci i swiszczacy oddech"),choices = list("Nie"=0,"Tak"=1),selected=0),
selectInput("select5",strong("Odkrztuszanie wydzieliny z krwia i chrypka"),choices = list("Nie"=0,"Tak"=1),selected=0),
selectInput("select6",strong("Guz w obrebie gruczolu piersiowego"),choices = list("Nie"=0,"Tak"=1),selected=0),
selectInput("select7",strong("Zmiany skorne wokol brodawki."),choices = list("Nie"=0,"Tak"=1),selected=0),
selectInput("select8",strong("Wyciek z brodawki (zwlaszcza krwisty)"),choices = list("Nie"=0,"Tak"=1),selected=0)
),
# Show a plot of the generated distribution
mainPanel(
plotlyOutput("distPlot")
)
)
)
}
#ploc krtani piersi,zdrowy
# Define server logic required to draw a histogram
klasyserver <- function(input, output,session) {
output$distPlot <- renderPlotly({
k=(0.01*as.numeric(input$slider1)+0.1*as.numeric(input$select1)+0.1*as.numeric(input$select2))*100
if(k>100){
k=100
}
p=(0.01*as.numeric(input$slider1)+0.1*as.numeric(input$select3)+0.1*as.numeric(input$select4)+0.1*as.numeric(input$select5))*100
if(p>100){
p=100
}
#print(p*100)
pi=(0.01*as.numeric(input$slider1)+0.1*as.numeric(input$select6)+0.1*as.numeric(input$select7)+0.1*as.numeric(input$select8))*100
if(pi>100){
pi=100
}
#print(pi*100)
z=100-(k+p+pi)/3
2021-01-17 21:11:11 +01:00
x=c("Rak krtani","Rak piersi","Rak pluc","Zdrowy")
2021-01-16 02:13:21 +01:00
y=c(k,pi,p,z)
d=data.frame(x,y)
print(d)
#z=0.0029*as.numeric(input$slider1)
g=ggplot(d, aes(x,y,fill=x))+
geom_col()+
2021-01-17 21:11:11 +01:00
labs(x="",y="Prawdopodobienstwo [%]")
2021-01-16 02:13:21 +01:00
ggplotly(g)
})
}