找回密码
 立即注册
查看: 3316|回复: 0

R-Shiny 运行报错

[复制链接]
发表于 2017-9-4 15:59:10 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|R语言中文网

GMT+8, 2024-11-22 20:27 , Processed in 0.025506 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表