请帮助我了解如何实施 CREATE TABLE AS SELECT
简单来说create table t1 as select * from t2; 我可以实现为
Create table t1 like t2;
insert into t1 as select * from t2;
但是如何实施 create table t1 as select c1,c2,c3 from t2;
有没有办法在黑斑羚中实现这个?
每当我尝试安装新软件包时,我都会收到此错误:
source("http://bioconductor.org/biocLite.R")
Warning in install.packages :
package ‘BiocInstaller’ is not available (for R version 3.0.2 RC)
Installing package into ‘/home/hd-master/R/x86_64-unknown-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://www.bioconductor.org/packages/2.13/bioc/src/contrib/BiocInstaller_1.12.0.tar.gz'
Content type 'application/x-gzip' length 13509 bytes (13 Kb)
opened URL
==================================================
downloaded 13 Kb
Error in library(BiocInstaller) :
there is no package called 'BiocInstaller'
Execution halted
Run Code Online (Sandbox Code Playgroud) 我想从 data.table 中获取第一个元素
library(data.table)
dt <- data.table(data.frame(prices=c(1.1,2.4,5.3),
dates = c(2011-01-04,2011-01-05,2011-01-03)))
dt
date value
1: 2011-01-04 1.1
2: 2011-01-05 2.4
3: 2011-01-03 5.3
> dt[1,1]
[1] 1
> dt[1]
date value
1: 2011-01-04 1.1
> dt[1][1]
date value
1: 2011-01-04 1.1
Run Code Online (Sandbox Code Playgroud)
我需要得到第一次约会。我不确定我在这里错过了什么:(
非常感谢。我对输出有点困惑。
dt[1, date]
[1] 2011-01-04
级别:2011-01-03 2011-01-04 2011-01-05(知道什么级别是什么意思吗?)
这也适用于 st$date[1]。实现与数据框相同。
我试图从数据框中获取JSON数组对象,其中每个JSON对象是数据框的子集
> x <- 1:5
> y <-c('a','b','c','d','e')
> z <-c(1,1,1,2,2)
> df <-data.frame(x,y,z)
> df
x y z
1 1 a 1
2 2 b 1
3 3 c 1
4 4 d 2
5 5 e 2
> rjson::toJSON(df)
[1] "{\"x\":[1,2,3,4,5],\"y\":[\"a\",\"b\",\"c\",\"d\",\"e\"],\"z\":[1,1,1,2,2]}"
> df1 = toJSONArray2(na.omit(df), json = F, names = F)
> rjson::toJSON(df1)
[1] "[[1,\"a\",1],[2,\"b\",1],[3,\"c\",1],[4,\"d\",2],[5,\"e\",2]]"
Run Code Online (Sandbox Code Playgroud)
我需要的输出是
[[[1,a],[2,b],[3,c]],[[4,d],[5,e]]]
下面的方法我能够按预期获得数据帧列表,但无法获得所需的json输出.
> x <- foreach(i=1:2) %do% { subset(df,df$z==i)[c(1,2)]}
> x
[[1]]
x y
1 1 a
2 2 b
3 3 …Run Code Online (Sandbox Code Playgroud) 有没有办法在里面拥有和处理空值std::basic_string?
有时传递的字符串序列具有空值.例如,下面的代码输出1234,5678而不是整个字符串.
#include <iostream>
#include <string>
#include <cstring>
int main ()
{
int length;
std::string str = "1234,5678\000,ABCD,EFG#";
std::cout << "length"<<str.c_str();
}
Run Code Online (Sandbox Code Playgroud)
我需要得到完整的字符串.