小编Pet*_*erV的帖子

Shiny 中的 conditionalPanel 不起作用

我正在尝试使用 conditionalPanel 在加载文件时显示消息。但是,一旦条件为真,面板就不会消失。我在下面创建了一个可重现的代码:

服务器

library(shiny)

print("Loading start")
print(paste("1->",exists('FGram')))
FGram <- readRDS("data/UGram.rds")
print(paste("2->",exists('FGram')))
print("Loading end")

shinyServer( function(input, output, session) {

})
Run Code Online (Sandbox Code Playgroud)

用户界面

library(shiny)

shinyUI( fluidPage(
  sidebarLayout(
    sidebarPanel(
      h4("Side Panel")
      )
    ),

    mainPanel(
      h4("Main Panel"),
      br(),
      textOutput("First Line of text.."),
      br(),
      conditionalPanel(condition = "exists('FGram')", HTML("PLEASE WAIT!!     <br>App is loading, may take a while....")),
      br(),
      h4("Last Line of text..")
    )
  )
)
Run Code Online (Sandbox Code Playgroud)

r shiny

6
推荐指数
1
解决办法
3827
查看次数

使用字典在Quanteda中创建Bigram

我试图从我的数据文本分析中删除拼写错误.所以我使用的是quanteda包的字典功能.它适用于Unigrams.但它为Bigrams提供了意想不到的输出.不知道如何处理错别字,以便他们不会潜入我的Bigrams和Trigrams.

ZTestCorp1 <- c("The new law included a capital gains tax, and an inheritance tax.", 
                "New York City has raised a taxes: an income tax and a sales tax.")

ZcObj <- corpus(ZTestCorp1)

mydict <- dictionary(list("the"="the", "new"="new", "law"="law", 
                      "capital"="capital", "gains"="gains", "tax"="tax", 
                      "inheritance"="inheritance", "city"="city")) 

Zdfm1 <- dfm(ZcObj, ngrams=2, concatenator=" ", 
         what = "fastestword", 
         toLower=TRUE, removeNumbers=TRUE,
         removePunct=TRUE, removeSeparators=TRUE,
         removeTwitter=TRUE, stem=FALSE,
         ignoredFeatures=NULL,
         language="english", 
         dictionary=mydict, valuetype="fixed")

wordsFreq1 <- colSums(sort(Zdfm1))
Run Code Online (Sandbox Code Playgroud)

电流输出

> wordsFreq1
    the         new         law     capital       gains         tax inheritance        city 
      0           0           0           0           0 …
Run Code Online (Sandbox Code Playgroud)

r quanteda

2
推荐指数
1
解决办法
1680
查看次数

标签 统计

r ×2

quanteda ×1

shiny ×1