我终于能够计算出我的抓取代码了.它似乎工作正常,然后突然再次运行它时,我收到以下错误消息:
Error in url[i] = paste("http://en.wikipedia.org/wiki/", gsub(" ", "_", :
object of type 'closure' is not subsettable
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我在代码中没有改变任何内容.
请指教.
library(XML)
library(plyr)
names <- c("George Clooney", "Kevin Costner", "George Bush", "Amar Shanghavi")
for(i in 1:length(names)) {
url[i] = paste('http://en.wikipedia.org/wiki/', gsub(" ","_", names[i]) , sep="")
# some parsing code
}
Run Code Online (Sandbox Code Playgroud) 我想从串行端口(USB 端口)读取数据流。
就我而言,它是来自 Arduino 板的数据,但我认为这个问题很普遍。
这在 R 中很容易完成。例如:
library(serial)
conn <- serialConnection("arduino", port="ttyUSB0", mode="9600,n,8,1") # port may be different on other machines and OS's
open(conn)
while(TRUE) { print(read.serialConnection(conn) ) }
Run Code Online (Sandbox Code Playgroud)
这将不断地将数据流吐出为文本(包括许多 NULL)。
我想在 Shiny App 中做类似的事情。尽管在此处对 R/Shiny 和数据流进行了出色的介绍,但我还没有设法使其正常工作:链接。下面有一个最小的非工作示例。
报告的错误是:argument 1 (type 'closure') cannot be processing by 'cat' which has been changed. 是print() 可以处理而renderText() 不能处理的数据类型问题吗?
library(shiny)
library(serial)
conn <- serialConnection("arduino", port="ttyUSB0", mode="9600,n,8,1")
open(conn)
ui <- fluidPage(
titlePanel("Shiny Data Serial Stream"),
fluidRow(
column(4,
hr(),
textOutput('serial'),
hr()
)
)
)
server …Run Code Online (Sandbox Code Playgroud) 请问有什么简单的方法如何允许 R Shiny 应用程序的用户(本地,而不是服务器上)从计算机中选择一个目录,然后输出路径?我找不到简单的方法,例如fileInput选择文件。我希望用户能够在整个PC上搜索文件夹,然后选择该文件夹,并且该文件夹的路径将显示在Shiny应用程序中,例如
C:\users\Jane\folder. 在下面的答案中,我只能搜索当前工作目录中的文件夹,而不是整个电脑,并且文件夹的路径不会显示在 Shiny 应用程序中。