How to skip missing files when downloading multiples files from the web?

前端 未结 1 950
滥情空心
滥情空心 2021-01-21 16:28

I have a question about downloading files. I know how to download files, using the download.file function. I need to download multiple files from a particular site,

1条回答
  •  无人及你
    2021-01-21 16:41

    You can do this using tryCatch. This function will try the operation you feed it, and provide you with a way to dealing with errors. For example, in your case an error could simply lead to skipping the file and ignoring the error. For example:

    skip_with_message = simpleError('Did not work out')
    tryCatch(print(bla), error = function(e) skip_with_message)
    # 
    

    Notice that the error here is that the bla object does not exist.

    0 讨论(0)
提交回复
热议问题