我有数千个列和行的数据文件.我想删除第一列,实际上是行计数器.我在linux中使用了这个命令:
cut -d " " -f 2- input.txt > output.txt
Run Code Online (Sandbox Code Playgroud)
但我的输出没有任何改变.有谁知道它为什么不起作用,我该怎么办?
这是我的输入文件的样子:
col1 col2 col3 col4 ...
1 0 0 0 1
2 0 1 0 1
3 0 1 0 0
4 0 0 0 0
5 0 1 1 1
6 1 1 1 0
7 1 0 0 0
8 0 0 0 0
9 1 0 0 0
10 1 1 1 1
11 0 0 0 1
.
.
.
Run Code Online (Sandbox Code Playgroud)
我希望我的输出看起来像这样:
col1 col2 col3 col4 …
Run Code Online (Sandbox Code Playgroud) 我想创建一个新的数据框,其中只包含两个独立的data.frame的公共行.例:
data.frame 1
1 id300
2 id2345
3 id5456
4 id33
5 id45
6 id54
Run Code Online (Sandbox Code Playgroud)
data.frame2
1 id832
2 id300
3 id1000
4 id45
5 id984
6 id5456
7 id888
Run Code Online (Sandbox Code Playgroud)
所以我希望我的输出是:
1 id300
2 id45
3 id5456
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?
我有两个尺寸相同的巨大矩阵.我想计算它们之间的欧几里德距离.我知道这是功能:
euclidean_distance <- function(p,q){
sqrt(sum((p - q)^2))
}
and if these are two matrices:
set.seed(123)
mat1 <- data.frame(x=sample(1:10000,3),
y=sample(1:10000,3),
z=sample(1:10000,3))
mat2 <- data.frame(x=sample(1:100,3),
y=sample(1:100,3),
z=sample(1:1000,3))
Run Code Online (Sandbox Code Playgroud)
然后我需要答案是一个新的矩阵3*3,显示mat1和mat2的每对值之间的欧几里德距离.
有什么建议吗?
我有15个不同的文件,我想要一个新文件,其中只包含所有文件中的公共行.例如:
File1:
id1
id2
id3
file2:
id2
id3
id4
file3:
id10
id2
id3
file4
id100
id45
id3
id2
I need the output be like:
newfile:
id2
id3
Run Code Online (Sandbox Code Playgroud)
我知道这个命令适用于每对文件:
grep -w -f file1 file2>输出
但我需要一个命令来工作超过2个文件.
有什么建议吗?