Make RStudio default software for opening data files (CSV/json etc.)


I want to minimise the time it takes me to go from a random csv file to a quick couple of ggplots and summarise tables. It's currently really fast to just open in Excel and create a chart but it doesn't have to be that way.

What I'd like for a CSV

The ability to set RStudio as the standard software for opening a csv. Then, when I open a file, RStudio opens, pulls the csv data into a dataframe and puts dplyr and ggplot2 in my library. That's it. Now I can start looking at the data however I would like.

Nice to have for all data files

If I could define my own script for the "open file" action that would be even better. I could decide that I want to add a different package that's useful for my specific function (e.g. I might always want some GIS functions for opening a particular file, but not everybody would)

This is more a system question than a rstudio question

1 Like

On a Mac you'd right-click a .csv file and select Get Info. From there you can change what application you want to use to open a file. In Choose Application, you'll have to change the dropdown "Enable All Applications", and then you can select RStudio (step by step instructions here.

Windows setup here

However, the above would just open the csv as a text file in RStudio, it wouldn't automatically import it.

I think there are ways of doing this, but it depends more on your system setup than RStudio itself.

You could probably make a shell script that launches RStudio and passes a file into a script (e.g. read.csv("<-path to file here->") — not actual code, that's just the idea).

On a Mac (which is what I'm on), you can use an application called Alfred to do "open file actions"

I'm pretty sure you can do the same thing using Mac Automator workflows, where you're, in essence, saying "when I do this, open this application, and use the selected file as a variable in this script that I want to run"

re. launching RStudio projects from the command line see here


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