我在一个tsv文件中有300000列,我只需要10000列。

2024-06-16 11:08:04 发布

您现在位置:Python中文网/ 问答频道 /正文

它们都以“rsid\u set(variable)”开头。我几乎没有编码经验,但一直在尝试使用R和python。有什么快速的方法可以得到我想要的那些专栏吗?你知道吗

追问:有没有办法取每列的平均值,把它变成一个有10000个值的正态分布?你知道吗


Tags: 方法编码经验variable平均值set办法正态分布
1条回答
网友
1楼 · 发布于 2024-06-16 11:08:04
# read in
df <- read.tsv("path/to/your/file")

# select only colnames beginning with rsid_set
df <- df[grep("^rsid_set",colnames(df)),] 

Your follow-up, I don't understand. You'll have to clarify what you want.

# Take the means of each column:
means <- colMeans(df)

# normal distribution with 10k values
norms <- rnorm(10e3)

相关问题 更多 >