我正在阅读文档,data.table并且还注意到了一些关于SO的对话,这些对话rbindlist应该比我更好rbind.
我想知道为什么rbindlist比真正优秀的rbind场景更好?rbindlistrbind
在内存利用方面有什么优势吗?
我正在尝试创建简单的webapp,我想使用HTML textarea控件从用户那里获取多行输入.有没有开箱即用的方式在Shiny中创建这样的输入控件?
textInput的帮助页面没有显示太多选项
textInput {shiny} R Documentation
Create a text input control
Description
Create an input control for entry of unstructured text values
Usage
textInput(inputId, label, value = "")
Arguments
inputId
Input variable to assign the control's value to
label
Display label for the control
value
Initial value
Value
A text input control that can be added to a UI definition.
Examples
textInput("caption", "Caption:", "Data Summary")
Run Code Online (Sandbox Code Playgroud) 我试图绑定列表中的元素的一些子元素
清单OC如下
> library(quantmod)
> OC <- getOptionChain('AAPL', NULL)
> str(OC)
List of 9
$ Feb 2013:List of 3
..$ calls :'data.frame': 35 obs. of 7 variables:
.. ..$ Strike: num [1:35] 380 390 400 410 420 430 440 445 450 455 ...
.. ..$ Last : num [1:35] 89.9 86 60 49.5 39.8 ...
.. ..$ Chg : num [1:35] 0 0 -0.4 -4.4 -0.7 -1.9 -0.55 -0.7 -0.95 -1 ...
.. ..$ Bid : num [1:35] …Run Code Online (Sandbox Code Playgroud) 如果我指定n列作为的一个关键data.table,我知道,我可以加入比,只要我加入到在项中定义的列数较少head的key(DT).例如,对于n = 2:
X = data.table(A=rep(1:5, each=2), B=rep(1:2, each=5), key=c('A','B'))
X
A B
1: 1 1
2: 1 1
3: 2 1
4: 2 1
5: 3 1
6: 3 2
7: 4 2
8: 4 2
9: 5 2
10: 5 2
X[J(3)]
A B
1: 3 1
2: 3 2
Run Code Online (Sandbox Code Playgroud)
在那里,我只加入了2列密钥的第一列DT.我知道我可以像这样加入密钥的两个列:
X[J(3,1)]
A B
1: 3 1
Run Code Online (Sandbox Code Playgroud)
但是,我如何仅使用键的第二列列(例如B==2)进行子集,但仍然使用二进制搜索而不是向量扫描?我知道这是一个副本:
使用二进制搜索而不是矢量扫描,仅按2列密钥的第二列对data.table进行子集化
所以我想把这个问题概括为n.我的数据集大约有一百万行,上面链接的复制问题提供的解决方案似乎并不是最优的.
我有简单的OHLC数据和XTS
SF <- structure(c(1.064, 1.07, 1.071, 1.08, 1.08, 1.076, 1.078, 1.08,
1.08, 1.082, 1.081, 1.082, 1.074, 1.07, 1.073, 1.075, 1.081,
1.084, 1.092, 1.091, 1.097, 1.095, 1.099, 1.094, 1.096, 1.097,
1.096, 1.096, 1.097, 1.091, 1.078, 1.083, 1.088, 1.084, 1.081,
1.095, 1.096, 1.085, 1.074, 1.075, 1.073, 1.07, 1.068, 1.072,
1.084, 1.08, 1.081, 1.077, 1.081, 1.083, 1.084, 1.083, 1.082,
1.082, 1.075, 1.074, 1.075, 1.092, 1.086, 1.092, 1.093, 1.098,
1.102, 1.103, 1.099, 1.098, 1.1, 1.101, 1.098, 1.098, 1.1, 1.092,
1.084, 1.087, 1.088, 1.084, 1.096, …Run Code Online (Sandbox Code Playgroud) 我有一个带标题的文本文件数据集
YEAR MONTH DAY value
Run Code Online (Sandbox Code Playgroud)
从2010年6月6日至2012年7月14日每小时运行一次.我使用以下命令打开并绘制数据:
data=read.table('example.txt',header=T)
time = strptime(paste(data$DAY,data$MONTH,data$YEAR,sep="-"), format="%d-%m-%Y")
plot(time,data$value)
Run Code Online (Sandbox Code Playgroud)
但是,绘制数据时,x轴仅显示2011年和2012年.
.如何保留2011年和2012年的标签,还要添加一些特定的月份,例如,如果我想要3月,6月和9月?
我已在此链接上提供数据
以下R代码只给出正态分布的一半; 为了获得另一半,我应该改变什么代码?
halfnormal <- function(n){
vector <- rep(0,n)
for(i in 1:n){
uni_random <- runif(2)
y <- -log(uni_random)
while(y[2] < (y[1]-1)^2/2){
uni_random <- runif(2)
y <- -log(uni_random)
}
vector[i] <- y[1]
}
vector
}
output <- halfnormal(1000)
hist(output)
Run Code Online (Sandbox Code Playgroud) r ×7
data.table ×2
rbind ×2
do.call ×1
rbindlist ×1
shiny ×1
statistics ×1
strptime ×1
textarea ×1
textinput ×1
time-series ×1
xts ×1