Created
July 13, 2017 07:28
-
-
Save dialektike/8c877a79135629544cce2ccd59d27b85 to your computer and use it in GitHub Desktop.
맥에서 read.any() 함수를 사용하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> temp_kbo <- read.csv("2017_7_8_KBO_win.csv", header = TRUE) | |
Error in make.names(col.names, unique = TRUE) : | |
'<bc><f8><c0><a7>'에서 유효하지 않은 멀티바이트 문자열이 있습니다 | |
> library(readr) | |
> read.any <- function(text, sep = "", ...) { | |
+ encoding <- as.character(guess_encoding(text)[1,1]) | |
+ setting <- as.character(tools::file_ext(text)) | |
+ if(sep != "" | !(setting %in% c("csv", "txt")) ) setting <- "custom" | |
+ separate <- list(csv = ",", txt = "\n", custom = sep) | |
+ result <- read.table(text, sep = separate[[setting]], fileEncoding = encoding, ...) | |
+ return(result) | |
+ } | |
> temp_kbo <- read.any("2017_7_8_KBO_win.csv", header = TRUE) | |
> head() | |
Error in head.default() : 기본값이 없는 인수 "x"가 누락되어 있습니다 | |
> temp_kbo <- read.any("2017_7_8_KBO_win.csv") | |
> head(temp_kbo) | |
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 | |
1 순위 선수명 팀명 AVG G PA AB R H 2B 3B HR TB RBI SAC SF | |
2 1 김선빈 KIA 0.38 79 303 271 49 103 23 0 2 132 47 2 4 | |
3 2 최형우 KIA 0.37 80 359 289 66 107 23 3 20 196 76 0 4 | |
4 3 나성범 NC 0.359 61 264 237 53 85 20 1 13 146 51 0 1 | |
5 4 김태균 한화 0.353 61 268 232 34 82 13 0 10 125 57 0 4 | |
6 5 서건창 넥센 0.353 78 347 303 52 107 17 2 4 140 49 0 3 | |
> temp_kbo <- read.any("2017_7_8_KBO_win.csv",header = TRUE) | |
> head(temp_kbo) | |
순위 선수명 팀명 AVG G PA AB R H X2B X3B HR TB RBI SAC SF | |
1 1 김선빈 KIA 0.380 79 303 271 49 103 23 0 2 132 47 2 4 | |
2 2 최형우 KIA 0.370 80 359 289 66 107 23 3 20 196 76 0 4 | |
3 3 나성범 NC 0.359 61 264 237 53 85 20 1 13 146 51 0 1 | |
4 4 김태균 한화 0.353 61 268 232 34 82 13 0 10 125 57 0 4 | |
5 5 서건창 넥센 0.353 78 347 303 52 107 17 2 4 140 49 0 3 | |
6 6 이대호 롯데 0.351 79 333 302 44 106 7 0 16 161 60 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment