首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >inherits(x,"character")在R编程闪亮的应用中不是真的

inherits(x,"character")在R编程闪亮的应用中不是真的
EN

Stack Overflow用户
提问于 2018-05-28 09:52:07
回答 1查看 967关注 0票数 1

我正在创建闪亮的应用程序,目的是输入文本文件,并使用udpipe库需要创建字云,注释等…

运行应用程序时,我收到"inherits(x,"character") is not TRUE“的提示。当我试图从Server.R文件返回datatable时,问题来自于"Annotate“Tab

ui.R代码:

代码语言:javascript
复制
shinyUI(
   fluidPage(

    ##today's date
     dateInput("date6", "Date:",
               startview = "decade"),
     ##current time
     h2(textOutput("CurrentTime")),
  # Application title
  titlePanel("UDPipe Text Analysis"),

  # Sidebar with a slider input for number of bins 
  sidebarLayout(
    sidebarPanel(
      # Input: for uploading a file ----
      fileInput("file1", "Choose Text File"),
      # Horizontal line ----
      tags$hr(),

      ##checkbox input
      checkboxGroupInput("upos",label = h4("Parts Of Speech to Show:"),
                         c("Adjective" = "ADJ",
                           "Propernoun" = "PROPN",
                           "Adverb" = "ADV",
                           "Noun" = "NOUN",
                           "Verb"= "VERB"),
      selected = c("ADJ","NOUN","VERB"),
      width = '100%'
      #choiceNames =
       # list(icon("Adjective"), icon("Adverb")),
      #choiceValues =
        #list("ADJ", "ADV")
      )),
mainPanel(
  tabsetPanel(type = "tabs",
              tabPanel("Overview",h4(p("Who deveoped this App")),
                       p("This app supports only text files. ", align = "justify"),
                       h4("Pupropse of this app"),
                       h4("what precaution to take")
              ),
              tabPanel("Annotate",dataTableOutput('Annotate'))

              )


)

server.R代码

代码语言:javascript
复制
library(shiny)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

  Dataset <- reactive({


    if (is.null(input$file)) { return(NULL) } else
    {

      Data <- readlines(input$file1)
      Data  =  str_replace_all(Data, "<.*?>", "")
      return(Data)

    }

  })  


  output$Annotate <- renderDataTable(
    {
      english_model = udpipe_load_model("./english-ud-2.0-170801.udpipe")
      x <- udpipe_annotate(english_model, x = Dataset)
      return(x)
    }
  )


  })

我正在尝试返回输出$Annotate变量中的数据表。但是它不能正常工作。

EN

回答 1

Stack Overflow用户

发布于 2018-05-28 16:35:54

将您的udpipe_annotate代码行替换为以下代码行。

代码语言:javascript
复制
txt <- as.character(Dataset())
udpipe_annotate(ud_dutch, x = txt, doc_id = seq_along(txt))

这将避免在您出色的应用程序中尚未加载文本数据时将NULL传递给udpipe_annotate

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50558174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档