|
R Shiny高手:
求助下。
UI.R
library(shiny)
library(DT)
library(dplyr)
library(tidyr)
shinyUI(pageWithSidebar(
headerPanel("FDC Raw data"),
sidebarPanel(
fileInput('file1', 'Choose CSV File',
accept=c('text/csv', 'text/comma-separated-values,text/plain')),
actionButton("goButton","转置"),
downloadButton('下载', 'Download')
),
mainPanel(
tabsetPanel(
tabPanel("Raw data",DT::dataTableOutput('contents')),
# tabPanel("转置后",DT::dataTableOutput("changefile"))
tabPanel("转置后",textOutput("changefile"))
)
)
))
server.R
options(shiny.maxRequestSize=30*1024^2)
shinyServer(function(input, output) {
inFile<-reactive({
if(is.null(input$file1))
return(NULL)
read.csv(input$file1$datapath,header=F)
})
output$contents <- DT::renderDataTable({
DT::datatable(inFile(),rownames=F)
})
Value<-eventReactive(input$goButton,{
names(inFile())<-c("cha","sensor","lot","0","user","device","recipe","opn","data","time","lanuch","x12","7","sp","wafer","p")
file<-group_by(inFile(),cha,sensor,lot,device,recipe,opn,sp,wafer)
file_m<-mutate(file,index=1:n())
file_s<-spread(file_m,key=sensor,value=data)
file_s()
#inFile()%>%dplyr::group_by(cha,sensor,lot,device,recipe,opn,sp,wafer) %>%
#dplyr::mutate(index=1:n()) %>%
#tidyr::spread(key=sensor,value=data)
})
output$changefile<-renderPrint({
Value()
})
#output$changefile<-DT::renderDataTable({
# DT::datatable(Value(),rownames=F)
#})
output$downloadData <- downloadHandler(
filename = function() { paste(input$file1, '.csv', sep='') },
content = function(file) {
write.csv(Value(), file)
}
)
}
)
运行会报错:Warning in body(fun) : argument is not a function
Warning in structure(x, class = unique(c("AsIs", oldClass(x)))) :
Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
Consider 'structure(list(), *)' instead.
Warning: Error in <-: invalid (NULL) left side of assignment
|
|