2
テキストファイルをRにアップロードすると、テキストが切り詰められてしまい、正確なカウントが得られません。テキストファイル全体が読み込まれるように、別のコマンドを使用する必要がありますか?RのテキストファイルRのすべてのテキストをロードしていません
あなたが最初にあなただけのどこにでもそれを保存し、その後、不適切な形でstr_count
を呼び出さずにテキストで読んでいるので、それだけの文字数を返しますR.現在における実際のオブジェクトにテキストを割り当てる必要
library(stringr)
> readr::read_file("Apple_Wikipedia.txt")
[1] "Apple Inc. is an American multinational technology company headquartered in Cupertino, California that designs, develops, and sells consumer electronics, computer software, and online services. The company's hardware products include the iPhone smartphone, the iPad tablet computer, the Mac personal computer, the iPod portable media player, the Apple Watch smartwatch, the Apple TV digital media player, and the HomePod smart speaker. Apple's consumer software includes the macOS and iOS operating systems, the iTunes media player, the Safari web browser, and the iLife and iWork creativity and productivity suites. Its online services include the iTunes Store, the iOS App Store and Mac App Store, Apple Music, and iCloud.\r\nApple was founded by Steve Jobs, Steve Wozniak, and Ronald Wayne in April 1976 to develop and sell personal computers. It was incorporated as Apple Computer, Inc. in January 1977, and sales of its computers saw significant momentum and revenue growth for the company.... <truncated>
> x <- c("Apple","ios", "iphone")
> str_count(x)
[1] 5 3 6