- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图编写一个Shiny应用程序,并且需要先操纵我的数据,然后才能开始对其进行可视化。我有三个输入来操纵数据。
1. channel
2.排除一个词
3.找到所有带有该词的评论
我能够完成前两个,但是在使用grep()函数查找包含某个单词的所有行时,我遇到了以下错误
“cat(list(...),file,sep,fill,labels,append)中的错误:
参数1(类型“列表”)不能由“猫”处理”
有人知道如何处理吗?或究竟是什么原因造成的?我认为是grep()函数正在使用列表来告诉我哪些行包含该单词。但是我不确定是否可以解决这个问题,并且已经花了很多时间在这上面
请在下面找到我的两个代码段;
用户界面
fluidPage(
titlePanel("Groupon Word Cloud"),
sidebarLayout(
sidebarPanel(
selectInput( inputId = "selection",
label = "Choose a Supply Channel",
choices = c('All',
'G1',
'Getaways',
'Goods',
'Live',
'National',
'N/A',
'MM'),
selected = 'All'),
hr(),
textInput( inputId = "exclude",
label = "Exclude a word"),
textInput( inputId = "drill",
label = "Drill down into a word"),
submitButton( text = "Update"),
hr(),
dateRangeInput( inputId = "date",
label = "Date Range",
start = "2015-02-01",
end = NULL ,
min = '2015-02-01',
max = NULL,
format = "yyyy-mm-dd",
startview = 'month',
weekstart = 0,
language = "en",
separator = "to"),
sliderInput( inputId = "freq",
label ="Minimum Frequency:",
min = 1,
max = 50,
value = 15),
sliderInput( inputId = "max",
label = "Maximum Number of Words:",
min = 1,
max = 300,
value = 100)),
# Show Word Cloud
mainPanel(
tableOutput('table')
)
library(shiny)
source('data/lappend.r')
#Load and manipulate data on App opening
survey_data <- read.delim(file = "data/Survey_Monkey_3_1_2015.txt"
, header = TRUE
, sep = "|"
, quote = ""
, stringsAsFactors = FALSE)
survey_data <- subset(survey_data, survey_data$Misc_Text_Feedback != '?')
survey_data <- survey_data[,c(2,6)]
stopWords <- read.csv (file = 'data/stop_words.csv')
stopWords <- as.character(stopWords[,2])
shinyServer(
function(input, output) {
#Data subset based on Supply Channel Selection
data <- reactive({
if (input$selection == 'All') {
if(input$drill==""){
survey_data
} else {
drill <- survey_data
drill <- grep(input$drill, drill$Misc_Text_Feedback, value = TRUE)
}
} else {
if(input$drill==""){
subset(survey_data, survey_data$Supply_Channel == input$selection )
} else {
drill <- subset(survey_data, survey_data$Supply_Channel == input$selection)
drill <- grep(input$drill, drill$Misc_Text_Feedback)
}
}
})
stops <- reactive({
stopWords <- lappend(stopWords, input$exclude)
return(stopWords)
})
#Table
output$table <- renderText({
data <- data()
head(data, n = 300)
})
})
lappend <- function(lst, obj) {
lst[[length(lst)+1]] <- obj
return(lst)
}
最佳答案
以我的经验,错误argument 1 (type 'list') cannot be handled by 'cat'
来自将列表传递给render ...()命令。我的猜测是您要将列表传递到server.r底部的output$table <- renderText({
。
另外,我所见过的renderText()
的所有示例仅呈现一行文本。如果要渲染多行,请尝试使用renderUI()
,它也可以处理某些类型的列表,例如Shiny自己的tagList()
。
关于R- Shiny | cat(list(...),file,sep,fill,labels,append)中的错误: argument 1 (type 'list' ) cannot be handled by 'cat' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29041449/
我发现一个有趣的事情,当在分隔符之后获取整个子字符串时,partition 比 split 更快。我已经在 Python 3.5 和 3.6 (Cpython) 中测试过 In [1]: s = 'v
我尝试将我的大数据框打印到 csv 文件,但制表符分隔 sep='\t'不起作用。然后我用换行符进行测试 sep='\n' ,看起来工作正常,用换行符打破所有元素。这里可能有什么问题? 代码很简单 d
使用 titleFormat 我有: $calendar.fullCalendar({ titleFormat: { month: 'MMMM yyyy',
正如我们所知,Windows 接受 "\" 和 "/" 作为分隔符。但是在python中,使用的是"\"。例如,调用 os.path.join("foo","bar"),将返回 'foo\\bar'。
从以下字符串“test S9.98 Sep”中,我想删除数字前面的 S。但不是来自使用 RegEx 的“test”或“Sep”。 我试过了 string result = Regex.Replace(
我正在为 MiRLAB 包的 R 教程苦苦挣扎,尽管我不确定问题是否与包的功能有关。 我想使用函数 Pearson(),它只接受 .csv 文件。我已经完美地加载了一个文件,但是当我尝试使用 Pear
一切都在标题中:) 我正在使用 org.json.CDL 将 JSONArray 转换为 CSV 数据,但它会呈现一个以“,”作为分隔符的字符串。我想知道是否可以用';'代替? 这是我正在做的一个简单
本文整理了Java中org.lilyproject.sep.ZooKeeperItfAdapter类的一些代码示例,展示了ZooKeeperItfAdapter类的具体用法。这些代码示例主要来源于Gi
我试图在 Freemarker 中的 迭代中迭代 JSON 对象,并以不同的形式写出相同的 JSON。对于某些情况,我想跳过迭代并且不写出任何内容,但 Freemakrer 仍然写出逗号,因为我使用
我有一个大文件,有一些规则的模式 snaps1: Counter: 4966 Opens: Counter:
我在我的网站上注意到,http://www.cscc.org.sg/ , 出现了这个奇怪的符号。 它说 L SEP。在 HTML 代码中,它显示相同的内容。 有人可以告诉我如何删除它们吗? 最佳答案
他们是一样的,但是我应该使用哪一个? http://docs.python.org/library/os.html : os.sep The character used by the operati
我尝试在第一页 hello world 中使用 Dust.js 模板引擎,但未能使用 {@sep} 标记,模板已编译并生成输出,但不是逗号 {@sep},{/sep} http://jsfiddle.
我无法使用括号作为分隔符来分隔列: d = data.frame(a = c('af(dsf', 'sdf (asdf', 'sdf(df')) d %>% separate(a, c('a','b'
我正在尝试读取使用 :: 作为列分隔符的文件: userID::MovieID::Rating::Timestamp 1::1193::5::978300760 1::661::3::97830210
标签 (id_tag,name) 新闻(id、标题、数据、标签) 字段 news>tags 是一个 varchar(255)。我打算将这样的数据放在该字段中:“1,7,34” 这意味着 news 中的
我正在学习 Python,只是想弄清楚如何打印多个 "*" 字符,这些字符由破折号分隔,但星号和破折号的数量可以通过用户。 这是我目前所拥有的: print('*' * n, sep = '-' *
这个问题在这里已经有了答案: Create list of single item repeated N times (9 个回答) How to print a list using splat-
数据: from io import StringIO import pandas as pd s = '''ID,Level,QID,Text,ResponseID,responseText,dat
我知道这通常是个坏主意,我已经阅读了 - 特别是 this question . 然而,总的规范化路线似乎更复杂,并且会给我和我的代码更多的障碍来跳过。这是我的场景: 我正在构建一个测试创建系统,用户
我是一名优秀的程序员,十分优秀!