2017-09-26 126 views

回答

0

斯堪的納維亞性狀有時需要特殊的編碼,即#ISO-8859-1 - 拉丁1以下是關於編碼(其不同於爲每個計算/ OS)

#Check what is your present encoding: 
getOption("encoding") 
#Modifiy the encoding 
options(encoding = "ISO-8859-1") 

#Optional: Check your system locale (Time, Monetary System, etc) 
Sys.getlocale() 
#Set an encoding, but it is OS-dependent what is installed 
Sys.setlocale("LC_ALL", locale ="swe") 

從readr文檔有用的命令:「默認編碼,隻影響文件的讀取方式 - 讀取器總是將輸出轉換爲UTF-8。「隨着read_fwf似乎你,可以指定一個區域設置/編碼:

read_fwf(file, col_positions, col_types = NULL, locale = default_locale(), 
na = c("", "NA"), comment = "", skip = 0, n_max = Inf, 
guess_max = min(n_max, 1000), progress = show_progress()) 

更換default_locale()locale(encoding= "latin1")。你的例子是不可複製的,因此很難測試它是否有效,但它應該看起來像:

my.data<- read_fwf('my.file', fwf_widths (c(2,2,2,8,2,4,40,1,1,10,10,4,2,11,32,1,4)), locale= locale(encoding= "latin1"), 
progress = interactive()) 
相關問題