-1
A
回答
0
movies.dat是在自述中描述::
只是一個txt文件DELIM。所以,你可以做到以下幾點:
txt <- readLines("./ml-1m/movies.dat", encoding = "latin1")
txt_split <- lapply(strsplit(txt, "::"), function(x) as.data.frame(t(x), stringsAsFactors=FALSE))
dat <- do.call(rbind, txt_split)
names(dat) <- c("MovieID", "Title", "Genres")
dim(dat) # 3883 3
它給你:
dim(dat) # 3883 3
head(dat)
MovieID Title Genres
1 1 Toy Story (1995) Animation|Children's|Comedy
2 2 Jumanji (1995) Adventure|Children's|Fantasy
3 3 Grumpier Old Men (1995) Comedy|Romance
4 4 Waiting to Exhale (1995) Comedy|Drama
5 5 Father of the Bride Part II (1995) Comedy
6 6 Heat (1995) Action|Crime|Thriller
PS:我不能弄清楚如何使用「標準」 R讀取方法,如read.table
,readr::read_delim
和data.table::fread
因爲他們需要1個字節的分離。在讀取數據之前,您可以嘗試將::
切換爲其他內容。 sed CLI
相關問題
- 1. 如何將鏈接添加到PDF文檔的文件附件
- 2. 鏈接到文檔附件的鏈接
- 3. 如何在R中導入.tsv文件?
- 4. 如何在R中導入ods文件
- 5. Phpmailer從鏈接添加PDF附件
- 6. 附加鏈接
- 7. R中導出錶鏈接
- 8. 如何從webView1中的鏈接加載webView2中的html文件
- 9. 將附件添加到pdf文件並附上鍊接
- 10. 如何將事件附加到鏈接早期附加方法的onSubmit事件?
- 11. 導入R中的文本文件
- 12. 如何從prestashop 1.5.x中獲得附件產品的鏈接?
- 13. Google附加鏈接
- 14. 如何從html文件中鏈接servlet
- 15. 如何自動鏈接CommonMark中的附近文件?
- 16. 從Carrierwave文檔附件的鏈接下載文件
- 17. 如何鏈接附加標題?
- 18. Facebook如何實現附加鏈接
- 19. 從R文件導入東西
- 20. 從XML文件導入數據到R
- 21. 從JSON文件導入數據到R
- 22. 從URL導入JSON文件到R
- 23. 如何使用R從下載鏈接下載文件
- 24. 附加(不想要的)在報頭中導入的.csv成R
- 25. 如何在Delphi中將事件附加到IHTMLDocument2鏈接元素?
- 26. Redmine:如何將項目中的附加文件與其欠項目鏈接?
- 27. 鏈接jQuery的附加
- 28. 附加到jQuery的鏈接
- 29. 恢復瀏覽的附件鏈接到文件輸入
- 30. 將多個csv文件從zip文件夾導入到R中