2016-07-21 6 views
-2

Rを使用してテキストファイルの平均文章長を見つける方法はありますか?または、Rを使うよりも良い方法がありますか?ちょっとした文脈を与えるために、私はプログラミングとこのフォーラムには全く新しいです。コードを共有するように人々に依頼するのが適切ですか?そうでない場合は、ヘルプページ/チュートリアルで誰かを指摘できますか?ここでテキストファイルの平均文章長にRを使用する

+2

ようこそ。 [Rで最小限の再現可能な例を提供する方法](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610)をお読みください。それに応じて編集して改善してください。良い投稿は通常、最小限の入力データを提供し、望ましい出力といくつかのコードが試行します - すべてコピー・ペーストが実行可能です。 – lukeA

答えて

0

は例です:

library(stringi) 
txt <- paste(readLines(n=10), collapse=". ") 
Do you remember the 
21st night of September 
Love was changing the minds of pretenders 
While chasing the clouds away 
Our hearts were ringing 
In the key that our souls were singing 
As we danced in the night 
Remember how the stars stole the night away 
Ba de ya - say do you remember 
Ba de ya - dancing in September 
summary(stri_length(stri_split_boundaries(txt, type = "sentence")[[1]])) 
    # Min. 1st Qu. Median Mean 3rd Qu. Max. 
    # 25.00 31.00 32.00 35.56 43.00 46.00 

あなたが望むものを達成するために、他の多くの方法がありますが、私は推測します。

関連する問題