Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 生成用于分析的伪数据_R_Linux_Bash_Paste_Shuffle - Fatal编程技术网

R 生成用于分析的伪数据

R 生成用于分析的伪数据,r,linux,bash,paste,shuffle,R,Linux,Bash,Paste,Shuffle,我试图生成伪数据来执行一些分析。我想洗牌 前6列,然后将其与第7列一起连接 一个小的示例文件可以很好地与脚本配合使用,并提供所需的输出 但是当我放置一个包含1000行和8644482列的文件时,命令永远不会结束 用这个脚本 我在这个论坛上读到,对于bigdata,我可以使用它 # install.packages("data.table") library(data.table) fread("bigDataFile.txt") 它给出了这个错误 possible actions: 1:

我试图生成伪数据来执行一些分析。我想洗牌 前6列,然后将其与第7列一起连接

一个小的示例文件可以很好地与脚本配合使用,并提供所需的输出

但是当我放置一个包含1000行和8644482列的文件时,命令永远不会结束 用这个脚本

我在这个论坛上读到,对于bigdata,我可以使用它

# install.packages("data.table")

library(data.table)

fread("bigDataFile.txt")
它给出了这个错误

possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 2
输入文件:

B01 1 0 0 1 -9 C C G G A G
B04 4 0 0 1 -9 C C G G A G
B40 40 0 0 1 -9 T C G G A G
B50 50 0 0 1 -9 T C G G A G
B73 73 0 0 1 -9 C C G G A A
B78 78 0 0 2 -9 C C G G A G
B86 86 0 0 2 -9 T C A A A G
B92 92 0 0 1 -9 T C A G 0 0
B93 93 0 0 2 -9 C C A G A G
B94 94 0 0 2 -9 T C G G G G
输出

B40 40 0 0 1 -9 C C G G A G
B93 93 0 0 2 -9 C C G G A G
B01 1 0 0 1 -9 T C G G A G
B92 92 0 0 1 -9 T C G G A G
B04 4 0 0 1 -9 C C G G A A
B86 86 0 0 2 -9 C C G G A G
B73 73 0 0 1 -9 T C A A A G
B78 78 0 0 2 -9 T C A G 0 0
B94 94 0 0 2 -9 C C A G A G
B50 50 0 0 1 -9 T C G G G G
使用的命令:

x <- read.table("genotypeSample.txt",sep="")

> y <- c(x[sample(1:nrow(x)),1:6], x[,7:12])

> write.table(y,"shufx.txt",row.names=FALSE,col.names=FALSE, quote=F)
xy write.table(y,“shufx.txt”,row.names=FALSE,col.names=FALSE,quote=F)
除了大文件问题之外,如果我想用这个脚本创建100个不同的文件,那么如何在循环中使用这个脚本

我还尝试了Linux命令来实现这一点。 在linux中Shuf-生成随机排列

cut -d" " -f1-6 genotypeSample.txt |shuf > a.txt

paste -d" " a.txt <(cut -d" " -f7- genotypeSample.txt)
for i in {1..100};do cut -d" " -f1-6 genotypeSample.txt |shuf  > a${i}.txt ;done

for i in {1..100}; do paste -d" " a${i}.txt <(cut -d" " -f7- genotypeSample.txt) > a$i.dat  ; done
cut-d”“-f1-6基因型sample.txt | shuf>a.txt
粘贴-d“a.txt a${i}.txt;完成
对于{1..100}中的i;粘贴-d“a${i}.txt a$i.dat;完成

我怎样修理它?

你可以切割一次;还消除了中间文件,应该加快一些

cut -d' ' -f1-6 genotypeSample.txt > a
cut -d' ' -f7-  genotypeSample.txt > b

for i in {1..100}; 
do 
    paste -d' ' <(shuf a) b > a$i.dat;
done
cut-d'-f1-6基因型sample.txt>a
剪切-d'-f7-基因型Sample.txt>b
对于{1..100}中的i;
做
粘贴-d''a$i.dat;
完成
ps.未测试