0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

R > 文字列操作 > 結合? > paste(x, collapse="") > strsplit()の場合はunlistしておく必要がある

Last updated at Posted at 2016-09-21
動作確認
RStudio 0.99.903 on Windows 7 pro
R version 3.3.1 

参考 Rで学ぶデータ・プログラミング入門 by 石田基広さん

paste()で分割した文字列をつけることができるようだ。

> x<-c("a","b","c")
> x
[1] "a" "b" "c"
> paste(x, collapse="")
[1] "abc"

ただし、以下は意図通り(zunzundoko)にならなかった。

> x<-strsplit("zunzundoko", "")
> x
[[1]]
 [1] "z" "u" "n" "z" "u" "n" "d" "o" "k" "o"

> paste(x, collapse = "")
[1] "c(\"z\", \"u\", \"n\", \"z\", \"u\", \"n\", \"d\", \"o\", \"k\", \"o\")"

教えていただいた事項

@r-de-r さんのコメントにてstrsplitとunlistを組合わせた方法を教えていただきました。

情報感謝です。

0
0
1

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?