Add tags

Add tags to the following comment

統計処理言語だけあって、Rでは、この手のデータ処理は非常に直感的です。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# タブ区切りのデータを読み込む
d <- read.delim("input.tsv")

# 第1カラムの値でデータを昇順にソートする。
d <- d[sort.list(d[,1]),]

# 第2カラムと第3カラムをヘッダを含めて入れ替える。
d[,c(2,3)] <- d[,c(3,2)]
colnames(d)[c(2,3)] <- colnames(d)[c(3,2)]

# 第4カラムの値にそれぞれ1を加える。
d[,4] <- d[,4] + 1

# 書き出す
write.table(d, "output.tsv", sep="\t", quote=F, row.names=F)

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...