在R中调整图形大小
我已经创建了下面的威布尔图,使用 我们首先为相同的对象创建一个数据帧在R中调整图形大小,r,charts,shiny,weibull,R,Charts,Shiny,Weibull,我已经创建了下面的威布尔图,使用 我们首先为相同的对象创建一个数据帧 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'
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")))
)
我无法更改图表大小。我请求有人指导我 通过将
高度
设置为700或800,即高度=700
,您的代码可以正常工作。谢谢。这似乎很难以捉摸
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