Search code examples
rboxrcurlread.table

How to read a table from a Box shared link (url) in R?


I need to read in a text file shared via Box.com - I'll use mtcars.txt as an example.

 WES.ped.exp <-
 read.table("https://ucsf.box.com/s/tht30egddqjqlq3koucqy7rhtzkh3ydi")

Problem is the shared link takes me to a viewer interface, from where one is supposed to click Download, and not directly to the plain .txt file.

When reading the table, it just reads HTML lines, like so:

enter image description here

I've tried curl, scan and just read.table , any ideas?


Solution

  • Go to the share setting of the file in question. Click on "Share", go to the settings, and make sure the file's shared link is set to "Anyone with the link can view and download this file", in order to generate a direct link.

    Go to the little settings icon, copy the "Direct Link", and paste it into the following:

    read.table("https://ucsf.box.com/shared/static/whateverthelinksays.txt")