Jonas van Nijnatten
Jonas van Nijnatten

Reputation: 35

How do I open an r script (.R file) in RStudio by double-clicking it in windows

When I double click an R script (.R file) in order to open and edit it, nothing happens. I expect it to open it in either R or RStudio but it doesn't.

I found a similar (old) question (Opening a .R file via a double click (Windows)) but the solution doesn't work for me.

I have tried: - right-clicking and explicitly telling it to open it with RStudio - set it as the default program to associate with this file type - drag the script into RStudio

Anyone any idea whether it is Windows or R(Studio) related?

Running: Windows 10 Pro R version 3.6.1 RStudio version 1.2.1335

Upvotes: 3

Views: 5348

Answers (1)

Oliver
Oliver

Reputation: 8572

As the first comment suggest, it is likely a problem occuring while installing R or Rstudio. This would most likely be fixed by reinstalling Rstudio. If it doesnt i'd suggest checking out this Rstudio question.

Basically, you can manually create using the command prompt (start -> "cmd" -> enter), using

assoc .R=rfile
Ftype rfile="C:\Program Files\RStudio\bin\rstudio.exe" %1

changing the rstudio directory to the correct directory for your computer.

A less command-prompty solution might be available by following the steps described in this guide. However i did not test the latter approach.

Upvotes: 1

Related Questions