我使用闪亮的
创建了以下魏布尔图我们首先为此创建一个数据框
DFF=data.frame('left'=c(13.5, 9.5, 5.5, 22.5, 4.5),'right'=c(13.5, 9.5,
5.5, 22.5, 4.5), 'qty'=c(3,4,3,4,1), 'event'=c(1,1,1,1,1), 'time'=
c(13.5,9.5, 5.5, 22.5, 4.5) )
write.csv(DFF, file = 'DFF.csv', row.names = F)
接下来,我们导入必要的包和库
require(shiny)
require(DMwR)
require(dplyr)
#Load packages
library(readxl)
library(WeibullR)
library(xlsx)
library(lubridate)
library(dplyr)
# We have imported the packages
# Step i create the skeleton shiny App
#现在,我们创建一个带有滑块的UI作为置信度输入
ui <- fluidPage(
titlePanel(title = "Tool", windowTitle = " Tool"),
h3(""),
hr(),
sidebarLayout(
sidebarPanel(
fluidRow(
column(12,
fluidRow(
column(5,
fileInput(inputId = "file", label = 'DF3',placeholder =
"No File Chosen",
multiple = TRUE,
accept = c("xlsx/xls",".xls",".xlsx"))),# We
have added the formats here- will load excel alone- in case csv/txt
needed amend here
column(5,sliderInput(inputId = "Slider", label = "Confidence
Interval", min = 0.5, max = 0.99, value = 0, step = 0.1)
)
)
) )
)
,mainPanel(plotOutput(outputId = "Plot")))
)
接下来,我们创建一个服务器以读取数据帧 #创建服务器
server <- function(input, output, session) {
output$Plot<- renderPlot({
infile <- input$file
if (is.null(infile)) {
# User has not uploaded a file yet
return(NULL)
}
#Create Dataframe from EXCEL FILE
DFF <- read.csv(input$file$datapath)
DF1 <- DFF[,c("left", "right", "qty")]
DF2<-DFF[,c("time", "event", "qty")]
weibull_fit<-mlefit(DF1,dist ="weibull")
weibull_fit<-round(weibull_fit,2)
#Create Weibull object
da1<-wblr(DF2)
da1 <- wblr.fit(da1 ,dist="weibull",method.fit="mle",pch=3)
da1<-
wblr.conf(da1,method.conf="lrb",
ci=as.numeric(input$Slider),col="Red")#pivotal-
P_Input<-"IA2028"
#Weibull Plot
plot(da1 ,main=paste("Partnumber:", P_Input, "Beta:",
round(weibull_fit[2],2),"Eta:",round(weibull_fit[1],2)))
})}
# deploy app
shinyApp(ui, server)
我已经部署了该应用程序。我正在密谋。调整图的高度时,出现错误。
# Change in this line in the UI
,mainPanel(plotOutput(outputId = "Plot", height = "100%")))
### Error- Error in pngfun: invalid 'width' or 'height'
,mainPanel(plotOutput(outputId = "Plot", height = "10")))
# Error: Figure margins too large
我无法更改图形大小。我要求有人来指导我。