Function

コメント・参照等

FUN = f_read_JobOpeningsFullEmployee.r
function (download_folder) 
{
    lapply(c("XLConnect", "Nippon", "lubridate"), require, character.only = T)
    path_to_folder <- paste0("C:/Users/", Sys.info()["user"], download_folder)
    setwd(path_to_folder)
    xls_file <- dir()
    for (sheet in 1:2) {
        buf0 <- readWorksheetFromFile(xls_file, sheet = sheet, check.names = F, header = F)
        colnames(buf0) <- paste0(buf0[2, ], ":", buf0[3, ], ":", buf0[1, ])
        buf1 <- buf0[-c(1:3), ]
        colnames(buf1)[1] <- "Date"
        buf1[, 1] <- gsub("(^[0-9]{4})-([0-9]{2})-.+", "\\1-\\2-1", buf1[, 1])
        buf2 <- buf1[!is.na(as.numeric(substring(buf1[, 1], 1, 4))), ]
        buf2[, 1] <- as.Date(buf2[, 1])
        buf2[, -1] <- apply(buf2[, -1], 2, function(x) as.numeric(gsub(",", "", x)))
        row.names(buf2) <- NULL
        colnames(buf2) <- sapply(colnames(buf2), zen2han)
        if (sheet == 1) {
            JobOpeningsFullEmployee <- buf2
        }
        else {
            JobOpeningsFullEmployee <- merge(JobOpeningsFullEmployee, buf2, all = T)
        }
    }
    return(JobOpeningsFullEmployee)
}

Asset Management Consulting Corporation