Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ベクトルxとする
x
[1] "hi" "hello" "Nyarlathotep"
ystからベクトルを生成することは可能ですか?xそのコンポーネントは次のとおりです。
y
[1] "hi" "hello" "Nyarl"
?
つまり、テキストの文字列を特定の長さ (上記では、長さ = 5) にカットする R のコマンドが必要になります。
どうもありがとう!
substring詳細を見る?substring
substring
?substring
> x <- c("hi", "hello", "Nyarlathotep") > substring(x, first=1, last=5) [1] "hi" "hello" "Nyarl"
最終更新sub正規表現で も使えます
sub
> sub("(.{5}).*", "\\1", x) [1] "hi" "hello" "Nyarl"