Websockets可以比普通的HTTP请求更快,浏览器通常可以打开更多的websocket连接.
我的浏览器通过javascript控制台告诉我,虽然我的闪亮应用程序正常工作,而apache proxypass正确代理,但websockets无效:
WebSocket connection to 'wss://www.example.com/shiny/01_hello/__sockjs__/058/v193lng7/websocket' failed: WebSocket is closed before the connection is established.
Run Code Online (Sandbox Code Playgroud)
我已经看到了Apache可以配置为代理websockets的不同方式.如:
ProxyPass /shiny/ ws://127.0.0.1:3838/
ProxyPass /shiny/ wss://127.0.0.1:3838/
RedirectMatch ^/shiny$ /shiny/
Run Code Online (Sandbox Code Playgroud)
和:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/$1 [P,L]
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
Run Code Online (Sandbox Code Playgroud)
我的问题是,这些中的任何一个都可以适应闪亮的使用吗?
有更清晰,更简单,更直接,更短的方式来做到这一点:
其中df1是数据帧:
names(df1[grep("Yield",names(df1))])
Run Code Online (Sandbox Code Playgroud)
我想返回任何包含单词yield的列名.
谢谢,
正常的R向量乘法,只将向量乘以一次,或者回收较短的向量.IE:
> c(2,3,4) * c(1,2)
[1] 2 6 4
Warning message:
In c(2, 3, 4) * c(1, 2) :
longer object length is not a multiple of shorter object length
Run Code Online (Sandbox Code Playgroud)
我想做的是将两个向量的每个组合相乘.在这种特殊情况下,我正在计算电动自行车电机可以旋转的MPH最大速度:*
d <- c(20,26,29) #bicycle wheel diameter possibilities in inches
rpm <- c(150,350) #maximum motor RPM. Choices depends on motor winding.
cir <- pi * d #circumference
mph <- cir * rpm / 63360 * 60 #max speed in mph for each wheel diameter and RPM combination
mph
Run Code Online (Sandbox Code Playgroud)
我想要的是mph包含给定车轮直径与给定最大电机RPM的每个最大速度组合.
*请注意,由于反电动势,它将在此速度下产生零扭矩.
我正在尝试使用具有四个可能模型"x1","x2","x3","x4"的名称的向量,并创建这些术语的所有可能排列的更长向量,因此我可以启动一个数据帧各自的属性.
下面的代码看起来应该可以工作但不会.元素不会粘贴在一起,例如"x1"和"x2"组合应该产生"x1x2"模型名称,而是保持"x1""x2".
models <- c("x1","x2","x3","x4")
modelist<- as.character()
for(i in 1:4){
modelist <- c(modelist,combn(models,m=i,FUN=paste0,simplify = T))
}
modelist
Run Code Online (Sandbox Code Playgroud)
由于我不是在寻找交互条件,x1x1不应该出现,但我有兴趣知道如何做到这两种方式以供将来参考.
这是我正在寻找的输出:
modelist <- c("x1","x2","x3","x4","x1x2","x1x3","x1x4","x2x3","x2x4","x3x4",
"x1x2x3","x2x3x4","x1x2x4","x1x3x4","x1x2x3x4")
Run Code Online (Sandbox Code Playgroud)
这就是模型师应该包含的内容.
我有一个RMarkdown文件,我用它来生成一个很好的HTML报告.问题是,我希望能够自动化它,以便它可以在无头服务器上运行.因此,没有人会在那里启动Rstudio并按下'knithtml'按钮,看起来Rstudio正在做很多额外的魔术,比如拥有它自己的pandoc版本,运行所有必要的命令,应用css样式等.
当我按下'knithtml'按钮时,如何通过运行R脚本来获取Rstudio生成的报告并生成相同的内容?
谢谢.
采用类似示例中的vbulletin网站.我希望能够从线程中删除文本消息.但是,消息的css选择器称为#post_message_xxx,其中xxx是变量id号.
如何将选择器与html_nodes部分匹配,以便我得到所有以#post_message开头的,无论它们如何结束?
或许我应该问一个更普遍的问题.如果我希望能够将作者归属于消息并跟踪消息顺序,我应该如何抓取页面.
谢谢.
library(rvest)
html <- html("http://www.acme.com/forums/new_rules_28429/")
cast <- html_nodes(html, "#post_message_28429")
cast
> <div id="post_message_28429"> Thanks for posting
> this. </div>
>
> attr(,"class")
[1] "XMLNodeSet"
Run Code Online (Sandbox Code Playgroud) 这是我的可重现示例:
library(rvest)
page <- html("http://google.com")
class(page)
page
> as.character(page)
Error in as.vector(x, "character") :
cannot coerce type 'externalptr' to vector of type 'character'
Run Code Online (Sandbox Code Playgroud)
如何将页面从 html 类转换为字符向量,以便将其存储在某处?
html_text 或 html_attr 之类的 html 函数没有给我完整的源代码。我想存储它,以便以后可以使用 html() 重新加载它。
谢谢。
我已经看到了其他一些帖子,他们建议将数据帧加载到列表中,但是他们从未解释过什么是可接受的方式来命名动态生成的数据帧.
我已经提出了下面的代码,我想知道这是否是一个好方法,或者我将来会遇到问题?
谢谢,
#create the data frames from all csv files into a list
dfs <- lapply(list.files(pattern="*.csv"),read.csv)
#Give them the correct names
names(dfs) <- regmatches(list.files(pattern="*.csv"),regexpr("^[[:alpha:]]+", list.files(pattern="*.csv")))
Run Code Online (Sandbox Code Playgroud)
另外,我可以命名它们并同时创建它们吗?我不想冒第二次调用时list.files以不同的顺序返回的风险,并且我在数据帧上添加了错误的名称.