[R] open a zip file

Glenn Schultz glennmschultz at me.com
Mon Aug 8 03:42:32 CEST 2016


All I have this code

 #=============== Function Downloads the Factor File
  #' A function to download FNMA Pool Factors
  #' 
  #' @importFrom httr GET
  #' @importFrom httr write_disk
  #' @importFrom httr http_status
  #' @importFrom httr progress
  #' @export
  FNMAPoolFactor <- function(){
    Year <- format(Sys.Date(), "%Y")
    Month <- format(Sys.Date(), "%m")
    response <- 
      httr::GET(
        paste("https://mbsdisclosure.fanniemae.com/disclosure-docs/monthly/",
            "mbs", 
            as.character(Month), 
            as.character(Year),
            ".zip", 
            sep = ""),
      httr::write_disk(paste("~/FNMA/mbs/",
                       as.character(Month), 
                       as.character(Year),
                       ".zip", 
                       sep = ""), overwrite = FALSE), httr::progress())
  httr::http_status(response)
  }

Which results in a zip file but I cannot open the file with unzip or any other R functions what have I done wrong?

Glenn



More information about the R-help mailing list