LoginSignup
2
2

More than 5 years have passed since last update.

Rのデータフレームでカンマを含むセルが存在する行を複数行に分ける

Last updated at Posted at 2015-10-16

bioinfomaticsだとRで

image

みたいなデータフレームを

image

みたくしたいことが多い気がします。

その場合splitstackshapeというパッケージが便利そうです。

> library(splitstackshape)
> hoge = read.csv("hoge.csv", header = F)
> hoge
               V1     V2
1 395,616,976,784 Q2MI39
2       100037489 Q0NZY6
> moge = cSplit(hoge, "V1", ",", direction = "long")
> moge
          V1     V2
1:       395 Q2MI39
2:       616 Q2MI39
3:       976 Q2MI39
4:       784 Q2MI39
5: 100037489 Q0NZY6

cSplitのソース

以上

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2