Giter Club home page Giter Club logo

Comments (14)

wush978 avatar wush978 commented on July 29, 2024

這是個Warning ,不是Error。
Error代表R 覺得100%有錯,Warning代表R 不確定這是不是個錯誤,但是可能是個錯誤。
感謝你的回報,我覺得教材應該要再加強這部份的說明。

另外這個incomplete final line可能來自於檔案的最後沒有斷行,以這個case來說是可以接受的。
也就是說,答案是utf-16le。

from datascienceandr.

nellArM avatar nellArM commented on July 29, 2024

在作業的最後面執行
read.table(file(orglist.path, encoding = "utf-16le"), header = TRUE, sep = ",")
好像會吃不到東西

from datascienceandr.

wush978 avatar wush978 commented on July 29, 2024

欸,我看懂了,我也重現了這個錯誤。

待我看看

from datascienceandr.

wush978 avatar wush978 commented on July 29, 2024

我猜測這是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.

torlin avatar torlin commented on July 29, 2024

我從作業上標示的網址直接下了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.

wush978 avatar wush978 commented on July 29, 2024

我是故意轉成UTF-LE給你們測的。

如果直接從網站上下載,應該是BIG5無誤。

請用教材中附屬的檔案,別用自己抓的版本。

謝謝

from datascienceandr.

torlin avatar torlin commented on July 29, 2024

誤會了不好意思orz

from datascienceandr.

b00501056 avatar b00501056 commented on July 29, 2024

所以助教,這題打下面這行
answer <- read.table(file(orglist.path, encoding = "UTF-16LE"), header = TRUE, sep = ",")

就算windows沒過 也會算分嗎

from datascienceandr.

wush978 avatar wush978 commented on July 29, 2024

Hmm... 我確認一下,windows上輸入submit會沒過嗎?

from datascienceandr.

b00501056 avatar b00501056 commented on July 29, 2024

有時候過 有時候沒過..
助教你知道要怎麼樣直接到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.

wush978 avatar wush978 commented on July 29, 2024

目前沒有好的方法。

如果你是利用bye()離開的話,swirl應該會有接關機制。

但是如果你不是的話,目前就是skip...了,或是用開發swirl課程的套件...

我會再把相關需求轉給swirl開發團隊,或是自己再改一版swirl。

from datascienceandr.

wush978 avatar wush978 commented on July 29, 2024

這個bug會在第一次作業結束之後,做修正。

並且在課程內容中新增運用readBin, stri_encodetextConnection解決這個問題的技巧。

from datascienceandr.

b00501056 avatar b00501056 commented on July 29, 2024

所以 這次作業最後一題只要寫出
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.

wush978 avatar wush978 commented on July 29, 2024

@b00501056

是的,基本上submit()有過就會拿滿分。

我比較擔心為什麼有時候submit()沒過... 這讓我很頭痛。

from datascienceandr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.