How do I upload a csv file from Dropbox to the R working directory ?

Hi!

Please help me solve this problem -
here is the Dropbox link:

here is an attempt to download this file and read its contents -

chem<-drop_read_csv("https://www.dropbox.com/s/md28vkpyq89u0bw/Plan%20of%20the%20Ministry%20of%20health%20of%20the%20Russian%20Federation%20for%202019-2024_1.csv?dl=0", dest = "D:\Temp")
chem

here is the message after executing this script: error and object not found -

Ошибка в curl::curl_fetch_disk(url, x$path, handle = handle) :
Failed to open file D:\Temp\Plan%20of%20the%20Ministry%20of%20health%20of%20the%20Russian%20Federation%20for%202019-2024_1.csv?dl=0.

chem
Ошибка: объект 'chem' не найден

Please tell me how to read the table using the Dropbox link I provided above?
Thanks!!

After download the file and placing it in my directory at PATH, the following worked for me

library(readr)
library(dplyr)
tmp <- read_csv("PATH/Plan of the Ministry of health of the Russian Federation for 2019-2024_1.csv")
#> Parsed with column specification:
#> cols(
#>   Years = col_double(),
#>   Mort.diseases.circulatory.system = col_double(),
#>   Mort.myocardial.infarction = col_double(),
#>   `Mort. acute.cerebrovascular.accident` = col_double(),
#>   `Ratio.x-ray endovasc.for.acute.coronary` = col_double(),
#>   Percentage.hospitalizations.acute.cerebral = col_double(),
#>   `High-tech.medical.care.in.NMIC` = col_double(),
#>   Re.Mort.diseases.circulatory.system = col_double(),
#>   Re.Mort.myocardial.infarction = col_double(),
#>   `Re.Mort. acute.cerebrovascular.accident` = col_double(),
#>   `Re.Ratio.x-ray endovasc.for.acute.coronary` = col_double(),
#>   Re.Percentage.hospitalizations.acute.cerebral = col_double(),
#>   `Re.High-tech.medical.care.in.NMIC` = col_double(),
#>   Caus.Mort.CVSys = col_character(),
#>   Prop.Caus.in.Mort.CVSys = col_double()
#> )
tmp %>% tibble()
#> # A tibble: 6 x 1
#>   .$Years $Mort.diseases.… $Mort.myocardia… $`Mort. acute.c… $`Ratio.x-ray e…
#>     <dbl>            <dbl>            <dbl>            <dbl>            <dbl>
#> 1    2019              545             37.1             86.2             43  
#> 2    2020              525             35.7             83               46.5
#> 3    2021              505             34.4             79.8             50  
#> 4    2022              485             33               76.7             53.5
#> 5    2023              465             31.6             73.5             57  
#> 6    2024              450             30.6             71.1             60  
#> # … with 10 more variables: $Percentage.hospitalizations.acute.cerebral <dbl>,
#> #   $`High-tech.medical.care.in.NMIC` <dbl>,
#> #   $Re.Mort.diseases.circulatory.system <dbl>,
#> #   $Re.Mort.myocardial.infarction <dbl>, $`Re.Mort.
#> #   acute.cerebrovascular.accident` <dbl>, $`Re.Ratio.x-ray
#> #   endovasc.for.acute.coronary` <dbl>,
#> #   $Re.Percentage.hospitalizations.acute.cerebral <dbl>,
#> #   $`Re.High-tech.medical.care.in.NMIC` <dbl>, $Caus.Mort.CVSys <chr>,
#> #   $Prop.Caus.in.Mort.CVSys <dbl>

Created on 2020-03-15 by the reprex package (v0.3.0)


That error message (assuming it's translated to English as object not found) means the object chem wasn't in your R environment when it was referenced. That suggesting that drop_read_csv(...) command had an error.

1 Like

Assuming you wanted to download straight from a dropbox URL, it's similar to downloading any csv given a URL.

A couple of issues to correct,

  • First, your use had an extra space at the end (csv?dl=0 " should be csv?dl=0")
  • Also, with dropbox, that extra url paramter ?dl=0" means don't download, and instead go to that dropbox meta page.
    If you change that to ?dl=1" you'll get a direct link to the csv file.

Then the following should load with public dropbox links,

library(readr)
library(dplyr)
tmp<- read_csv("https://www.dropbox.com/s/md28vkpyq89u0bw/Plan%20of%20the%20Ministry%20of%20health%20of%20the%20Russian%20Federation%20for%202019-2024_1.csv?dl=1")
#> Parsed with column specification:
#> cols(
#>   Years = col_double(),
#>   Mort.diseases.circulatory.system = col_double(),
#>   Mort.myocardial.infarction = col_double(),
#>   `Mort. acute.cerebrovascular.accident` = col_double(),
#>   `Ratio.x-ray endovasc.for.acute.coronary` = col_double(),
#>   Percentage.hospitalizations.acute.cerebral = col_double(),
#>   `High-tech.medical.care.in.NMIC` = col_double(),
#>   Re.Mort.diseases.circulatory.system = col_double(),
#>   Re.Mort.myocardial.infarction = col_double(),
#>   `Re.Mort. acute.cerebrovascular.accident` = col_double(),
#>   `Re.Ratio.x-ray endovasc.for.acute.coronary` = col_double(),
#>   Re.Percentage.hospitalizations.acute.cerebral = col_double(),
#>   `Re.High-tech.medical.care.in.NMIC` = col_double(),
#>   Caus.Mort.CVSys = col_character(),
#>   Prop.Caus.in.Mort.CVSys = col_double()
#> )
tmp %>% tibble
#> # A tibble: 6 x 1
#>   .$Years $Mort.diseases.… $Mort.myocardia… $`Mort. acute.c… $`Ratio.x-ray e…
#>     <dbl>            <dbl>            <dbl>            <dbl>            <dbl>
#> 1    2019              545             37.1             86.2             43  
#> 2    2020              525             35.7             83               46.5
#> 3    2021              505             34.4             79.8             50  
#> 4    2022              485             33               76.7             53.5
#> 5    2023              465             31.6             73.5             57  
#> 6    2024              450             30.6             71.1             60  
#> # … with 10 more variables: $Percentage.hospitalizations.acute.cerebral <dbl>,
#> #   $`High-tech.medical.care.in.NMIC` <dbl>,
#> #   $Re.Mort.diseases.circulatory.system <dbl>,
#> #   $Re.Mort.myocardial.infarction <dbl>, $`Re.Mort.
#> #   acute.cerebrovascular.accident` <dbl>, $`Re.Ratio.x-ray
#> #   endovasc.for.acute.coronary` <dbl>,
#> #   $Re.Percentage.hospitalizations.acute.cerebral <dbl>,
#> #   $`Re.High-tech.medical.care.in.NMIC` <dbl>, $Caus.Mort.CVSys <chr>,
#> #   $Prop.Caus.in.Mort.CVSys <dbl>

Created on 2020-03-15 by the reprex package (v0.3.0)

2 Likes
  • thank you so much for your help!
    I did it:

library(readr)
library(dplyr)
tmp<- read_csv("https://www.dropbox.com/s/md28vkpyq89u0bw/Plan%20of%20the%20Ministry%20of%20health%20of%20the%20Russian%20Federation%20for%202019-2024_1.csv?dl= 1 ")

a message appeared:

Ошибка в open.connection(con, "rb") :
Timeout was reached: [www.dropbox.com] Connection timed out after 10000 milliseconds

tmp
Ошибка: объект 'tmp' не найден

(Error in open.connection)

(Error: 'tmp' object not found)

how do I solve this problem?

The code from EconomiCurtis worked fine for me:

library(readr)
library(dplyr)
tmp <- read_csv("https://www.dropbox.com/s/md28vkpyq89u0bw/Plan%20of%20the%20Ministry%20of%20health%20of%20the%20Russian%20Federation%20for%202019-2024_1.csv?dl=1")

head(tmp)
# A tibble: 6 x 15
  Years Mort.diseases.c~ Mort.myocardial~ `Mort. acute.ce~ `Ratio.x-ray en~ Percentage.hosp~
  <dbl>            <dbl>            <dbl>            <dbl>            <dbl>            <dbl>
1  2019              545             37.1             86.2             43                 76
2  2020              525             35.7             83               46.5               79
3  2021              505             34.4             79.8             50                 83
4  2022              485             33               76.7             53.5               87
5  2023              465             31.6             73.5             57                 91
6  2024              450             30.6             71.1             60                 95
# ... with 9 more variables: `High-tech.medical.care.in.NMIC` <dbl>,
#   Re.Mort.diseases.circulatory.system <dbl>, Re.Mort.myocardial.infarction <dbl>, `Re.Mort.
#   acute.cerebrovascular.accident` <dbl>, `Re.Ratio.x-ray endovasc.for.acute.coronary` <dbl>,
#   Re.Percentage.hospitalizations.acute.cerebral <dbl>, `Re.High-tech.medical.care.in.NMIC` <dbl>,
#   Caus.Mort.CVSys <chr>, Prop.Caus.in.Mort.CVSys <dbl>

Perhaps something else is interfering with your connection: are you operating behind a proxy server? Is your antivirus/security software blocking access?
HTH

1 Like
  • thank you very much for your support!

I contacted our system administrator, who configured R to work through a proxy server.

  • this information helped configure the settings:
  • it was especially important to perform: ...
  1. For RStudio just you have to do this:Firstly, open RStudio like always, select from the top menu:Tools-Global Options-PackagesUncheck the option: Use Internet Explorer library/proxy for HTTP
  2. Find the file ( .Renviron ) in your computer, most probably you would find it here: C:\Users\your user name\Documents .Note that: if it does not exist you can create it just by writing this command in R:
file.edit('~/.Renviron')

Then add these six lines to the initials of the file:

options(internet.info = 0)

http_proxy = https:// user_id:password@your_proxy:your_port

http_proxy_user = user_id:password

https_proxy = https:// user_id:password0@your_proxy:your_port

https_proxy_user = user_id:password

ftp_proxy = user_id:password@your_proxy:your_port
  1. Restart R. Type the following commands in R to assure that the configuration above works well:
Sys.getenv("http_proxy")

Sys.getenv("http_proxy_user")

Sys.getenv("https_proxy")

Sys.getenv("https_proxy_user")

Sys.getenv("ftp_proxy")
  1. Now you can install the packages as you want by using the command like:
install.packages("mlr",method="libcurl")
  • the problem is completely solved!! :blush:

Once again, thank you all very much!! It was very nice to receive your recommendations, without which we would not have managed on our own... I wish you all health and creative success!
E. Lenko, Russia.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.