Skip to content

Instantly share code, notes, and snippets.

@dialektike dialektike/read_any.R
Last active Jul 13, 2017

Embed
What would you like to do?
r에서 한글문서 열때 인코딩 문제 해결 함수. 참고: http://philogrammer.com/2017-03-15/encoding/
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.