0
我有一個閃亮的應用程序,必須讀取由客戶端提供的大表並執行一些計算。 爲此,我用的fread下面的函數內fread性能和shinnyapp
read_shiny_files=function(path){
file = data.table::fread(path,stringsAsFactors = F,header=TRUE,data.table=FALSE,skip=0)
rownames(file)=make.names(samples(file[,1]),unique=TRUE)
file=file[,-1]
return(file)
}
然後我允許基於用戶的一些數據預處理參數
read_files=function(features_list,rm,rmv,im,imv,nr){
features_list=lapply(features_list,read_shiny_files)
#remove rows and columns with more than rmv missing values
if(rm==TRUE) features_list=lapply(features_list,remove_missing,rmv)
#impute based on imv neighbours. Method based on Troyanskaya et al
if(im==TRUE) features_list=lapply(features_list,function(x,imv) t(impute.knn(t(x),k=imv)$data),imv)
if(nr==TRUE) features_list=lapply(features_list,standardNormalization)
return(features_list)
}
運行在RStudio此功能20M的表花費不超過2秒 但隨着閃亮絕對需要更多的時間(幾乎一分鐘)。無論是使用RunApp在本地運行它,還是在shinyapp.io網絡應用程序上使用它,都會發生這種情況 您能幫我提高速度嗎?
這裏是我已經寫了什麼
> fl=reactive({
> validate(
> need(input$files$datapath != "", "Please select a data set")
> ) read_files(features_list=input$files$datapath,input$rm,input$rmv,input$im,input$imv,input$nr)
> })
PS
我也改變server.R參數來改變表最大尺寸(5M的限制)
options(shiny.maxRequestSize=100*1024^2)