download.file() issue, corrupted file

I don't know if this is the best way to handle this multi-OS situation but I use a very similar approach, I use this function to get the OS and perform some tasks accordingly, obviously, this is not a general solution since it only works for the operating systems that I use, but it can give you an idea.

get_os <- function(){
    sysinf <- Sys.info()
    os <- sysinf['sysname']
    if (os == 'Darwin'){
        os <- "osx"
    } else {
        os <- .Platform$OS.type
        if (grepl("^darwin", R.version$os))
            os <- "osx"
        if (grepl("linux-gnu", R.version$os))
            os <- "linux"
        if (grepl("linux-gnueabihf", R.version$os))
            os <- "raspbian"
    }
    tolower(os)
}

This is supposed to be Windows-only but I have tested it on Ubuntu and it works normally so I would say, give it a try.

1 Like