看板 R_Language 關於我們 聯絡資訊
最近要用 R 去讀 matlab 的 mat 檔,matlab 檔的內容為: n 個 cell ,每個cell 都存 一個中文字串,發現利用 R.matlab 中的 readMat 去讀取,會有以下警告訊息:在強制 變更成純量時,任何溢位值當作0來處理。 這讀取的結果會無法顯示任何中文訊息。 請問各位大大有什麼好辦法嗎? 範例:MATLAB: test{1,1}='貓' test{2,1}='狗' test{3,1}='犀牛' test{4,1}='非洲大草原' save test.mat R: library(R.matlab) path = system.file("mat-files", package="R.matlab") pathname = file.path('C:\\Users\\JACK\\\Desktop','test.mat' ) data1 = readMat(pathname) Warning: 1: In convertUTF8(ary) : 在強制變更成純量值時,任何溢位值當作 0 來處理 output: "" 輸出是空的list -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.136.91.165 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1495700479.A.002.html
andrew43: 要不要生成一個類似資料的假mat檔讓大家試? 05/25 16:26
※ 編輯: jackhzt (140.109.73.209), 05/25/2017 16:56:12
celestialgod: 請愛用rmatio這個套件 05/25 17:52
celestialgod: http://imgur.com/a/4JU7T 05/25 18:14
celestialgod: 不過基本上CJK文字要經過轉換,除非是在unix-like 05/25 18:14
celestialgod: 還有v7跟v7.3版本的mat都會有問題 05/25 18:16
celestialgod: 一定要用v6版本(攤手 05/25 18:16
celestialgod: 或是選擇不壓縮 05/25 18:16
jackhzt: 剛剛試了一下 rmatio 但是出現已下訊息 : 05/25 18:19
jackhzt: Character data not supported type: 17Character data n 05/25 18:20
celestialgod: 注意 7跟7.3版本的mat不支援,save要用加個-v6 05/25 18:20
jackhzt: not supported type: 17 05/25 18:20
jackhzt: 成功沒有警告消息了 05/25 18:50
jackhzt: 正在用iconv編碼 不知道這是甚麼碼到甚麼碼 05/25 18:51
celestialgod: 看了一下,是轉成mat_uint8_t 05/25 18:55
celestialgod: CJK文字應該是沒救了 05/25 18:55
celestialgod: https://goo.gl/bN7dsW 05/25 18:55
jackhzt: 看來是沒救惹? 好巴 QQ 05/25 18:57
celestialgod: 更正是用char存 05/25 18:59
celestialgod: https://goo.gl/q9kB4R 05/25 18:59
celestialgod: 用其他格式儲存吧(攤手 05/25 19:01
jackhzt: 那還有救嗎? 05/25 19:01
celestialgod: excel是一個不錯的選擇XD 05/25 19:01
jackhzt: XDDDDD 看來要這一步要放棄使用R了 05/25 19:03
jackhzt: 謝謝C大 <3 05/25 19:04
celestialgod: http://imgur.com/a/PkcQs 05/25 19:08