Function

コメント・参照等
  • 日銀短観zipファイルを読み込む関数

FUN = f_read_tankan.r
function (dest_folder) 
{
    path_to_folder <- paste0("C:/Users/", Sys.info()["user"], dest_folder)
    setwd(path_to_folder)
    zip_file <- dir(pattern = "zip$")
    tankan <- lapply(zip_file, function(x) {
        tmp <- read.csv(file = unzip(x), header = F, stringsAsFactors = F, row.names = NULL, check.names = F)
        tmp[, 4] <- as.numeric(tmp[, 4])
        tmp <- tmp[!is.na(tmp[, 4]), ]
        row.names(tmp) <- NULL
        return(tmp)
    })
    return(tankan)
}