Comments (14)
這是個Warning ,不是Error。
Error代表R 覺得100%有錯,Warning代表R 不確定這是不是個錯誤,但是可能是個錯誤。
感謝你的回報,我覺得教材應該要再加強這部份的說明。
另外這個incomplete final line可能來自於檔案的最後沒有斷行,以這個case來說是可以接受的。
也就是說,答案是utf-16le。
from datascienceandr.
在作業的最後面執行
read.table(file(orglist.path, encoding = "utf-16le"), header = TRUE, sep = ",")
好像會吃不到東西
from datascienceandr.
欸,我看懂了,我也重現了這個錯誤。
待我看看
from datascienceandr.
我猜測這是R + Windows 在處理UTF-16的一個bug。windows好像在UTF-16上有一些bug...
透過套件stringi,以下的程式碼可以正確的讀取檔案:
src <- readBin(orglist.path, "raw", file.info(orglist.path)$size)
src2 <- stri_encode(src, "UTF-16LE", "UTF-8")
con <- textConnection(src2)
answer <- read.table(con, header = TRUE, sep = ",")
但是這樣寫作業反而不會過 Orz...
要用answer <- read.table(file(orglist.path, encoding = "UTF-16LE"), header = TRUE, sep = ",")
才能通過。寫出這行,我作業會算分。
UTF-16LE讀取失敗的問題,我會在下次上課的時候跟同學們說明。
感謝你的發問
from datascienceandr.
我從作業上標示的網址直接下了CSV檔
readbin結果是22 be f7
用BIG5跟UTF-16LE下去試,結果BIG5才會正常顯示,UTF-16LE出亂碼(結果丟下面)
看來我抓的檔案編碼是BIG5…吧?
但作業裡寫answer<-read.table(file(orglist.path,encoding="BIG5"), header=TRUE, sep=",")又不會過…
readLines(file(orglist.path, encoding = "BIG5"), n=3)
[1] ""機關代碼","機關名稱","郵遞區號","機關地址","機關電話","主管機關代碼","主管機關名稱","傳真","機關生效日期","機關裁撤日期","機關層級","裁撤註記","新機關代碼","新機關名稱","新機關生效日","舊機關代碼","舊機關名稱""
[2] ""100000000A","國民大會","100","台北市中華路一段五三號","02-23311312","100000000A","國民大會","02-23117703","0000000","","1","","","","","","""
[3] ""101000000A","國民大會憲政研討委員會","","","","100000000A","國民大會","","0000000","0930909","2","是","","","","","""
readLines(file(orglist.path, encoding = "UTF-16LE"), n=3)
[1] "븢쏷\ua5f6뵎≘∬垦"
from datascienceandr.
我是故意轉成UTF-LE給你們測的。
如果直接從網站上下載,應該是BIG5無誤。
請用教材中附屬的檔案,別用自己抓的版本。
謝謝
from datascienceandr.
好
誤會了不好意思orz
from datascienceandr.
所以助教,這題打下面這行
answer <- read.table(file(orglist.path, encoding = "UTF-16LE"), header = TRUE, sep = ",")
就算windows沒過 也會算分嗎
from datascienceandr.
Hmm... 我確認一下,windows上輸入submit
會沒過嗎?
from datascienceandr.
有時候過 有時候沒過..
助教你知道要怎麼樣直接到submit 不用回答那些問題嗎=
謝謝助教
從: Wush Wu [[email protected]]
寄件日期: 2015年10月26日 下午 10:56
至: wush978/DataScienceAndR
副本: 藍浩佑
主旨: Re: [DataScienceAndR] 有關orglist-100.csv (#80)
Hmm... 我確認一下,windows上輸入submit會沒過嗎?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/80#issuecomment-151164459.
from datascienceandr.
目前沒有好的方法。
如果你是利用bye()
離開的話,swirl應該會有接關機制。
但是如果你不是的話,目前就是skip
...了,或是用開發swirl課程的套件...
我會再把相關需求轉給swirl開發團隊,或是自己再改一版swirl。
from datascienceandr.
這個bug會在第一次作業結束之後,做修正。
並且在課程內容中新增運用readBin
, stri_encode
和textConnection
解決這個問題的技巧。
from datascienceandr.
所以 這次作業最後一題只要寫出
answer <- read.table(file(orglist.path, encoding = "UTF-16LE"), header = TRUE, sep = ",")
這樣就可以拿到滿分了吧?
謝謝助教用心的出作業,覺得很棒 謝謝
從: Wush Wu [[email protected]]
寄件日期: 2015年10月26日 下午 11:12
至: wush978/DataScienceAndR
副本: 藍浩佑
主旨: Re: [DataScienceAndR] 有關orglist-100.csv (#80)
這個bug會在第一次作業結束之後,做修正。
並且在課程內容中新增運用readBin, stri_encode和textConnection解決這個問題的技巧。
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/80#issuecomment-151169136.
from datascienceandr.
是的,基本上submit()
有過就會拿滿分。
我比較擔心為什麼有時候submit()
沒過... 這讓我很頭痛。
from datascienceandr.
Related Issues (20)
- omnitest(correctVal = ...) ==> val_is
- XQuartz issue on Mac
- Problems in installation: package or namespace load failed for ‘curl’ in get(method, envir = home): HOT 3
- 01-RBasic-04 answer3 順序會影響答案的判斷
- 02-05 大魔王的提示訊息有誤
- 少許的錯字
- 有同學反應,想在課程筆記中加入comments的內容 HOT 1
- 02-04 在 windows R3.5.1 上會出bug HOT 1
- check_then_install
- 01-RBasic-07-Loading-Dataset的step 25 HOT 1
- Create Jenkins CI for test package compatibility HOT 1
- 避免 browseURL 在測試時運作 HOT 1
- 03-RVisualization-04-Javascript-And-Maps 因為ggmap的問題,改成用leaflet撰寫圖資視覺化的範例(需要測試)
- 將DSR-server一併整合至測試環境
- 利用R版本與套件版本建構pre-build package加速測試 HOT 1
- Under testing: `Error in rsqlite_fetch(res@ptr, n = n) : external pointer is not valid`
- dplyr vignettes renaming
- 績效值長條圖問題
- 安裝swirl出現Error in loadNamespace(name) : there is no package called ‘pvm’
- Console出現奇怪的文字 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datascienceandr.