I am guessing you are using Windows. The problem is probably that Windows does not know which program to use to open a .R file. To fix that, click the search icon that is next to the Windows icon at the bottom left of your screen. Search for Default Apps. Open the default apps tool and scroll down the list on the right side and click on Choose Default Apps By File Type. A long list will appear and it might take a few seconds for the list to fill. Scroll down to find the .R extension. Click on the name of the app that appears there and choose RStudio as the alternative.