I know how to start a new project in Rstudio. I've been doing that for the past months in my work laptop. However, when I started an R project in my personal laptop I noticed that the default working directory wasn't where I had setup my project directory. I know this is not supposed to happen because I haven't seen an issue like this in my work laptop.
I searched through google and stackoverflow, but I could find anything useful. The only question that I found similar to my problem is the one here. OP answered his own question saying that he modified the Rprofile.site. But I can't do the same with mine. Any pointers please.
When you say default working directory, do you mean the folder that RStudio points to when you are not using an R project?
It sounds like you were expecting RStudio to point to your project directory but it isn't. Can you confirm that the project is open? In the upper righthand corner, you should see your project name next to a blue cube R project icon.
Yes, I expect RStudio project to point to my project directory, but it's instead pointing to the 'original directory', that is the directory when I am not inside a project. I can confirm that the project is open as I can see its name next to the blue cube. I have no problem in my work laptop, but I do in my personal laptop.
When I run rprojroot::find_rstudio_root_file() inside my project I get the following error message:
Error: No root directory found in C:/xxxx/xxx/xxx/xxx or its parent directories. Root criterion: contains a a file matching [.]Rproj$ with contents matching ^Version: in the first line.
Thanks @Dieg11 - my first piece of advice for addressing this is to upgrade RStudio to the latest version. There is a slightly newer version out there (1.1.456). Can you upgrade on your machine and then see if this behavior persists?
Thanks for following up @Dieg11 - if you have a project opened (verified by looking at the upper righthand corner of the screen that shows the project name) and rprojroot::find_rstudio_root_file() still returns an error, can you follow-up with your operating system name and version as well as the version of R you use?
I would also recommend uploading a screenshot that shows both the rprojroot::find_rstudio_root_file() error and the project open in the upper righthand corner. That will be helpful information along with the output of devtools::session_info() or, at least, sessionInfo().
Thanks @Dieg11! It looks like you are missing a dependency for devtools - can you run install.packages("Rcpp") and then try to get that session_info() output as well?
One more piece of follow-up @Dieg11 - once you've got the devtools::session_info() output, I would open a new issue on RStudio's GitHub "Issues" tab. Include the screenshot you showed me, which confirms that you've got the workflow down and this is more likely to be a bug, and the other info you've pulled together (OS, version of R/RStudio, devtools::session_info() output). You can also link back to this thread if you like.
You might consider resetting your project's state;
If you are using RStudio Projects, we'd also recommend resetting the project-specific state if you're having issues - you can do this by navigating to the Project's folder in your file browser, and renaming the .Rproj.user directory there.
Also check out the RStudio support guide,
You can use an .Rprofile to ensure your working directory is set to your project's directory.
Note the message output during install, that says "unable to move temporary installation to <...>". This implies that the package was downloaded, but wasn't successfully copied into your library paths.
This is a frustrating Windows issue, and can occur if a different instance of R / RStudio is open, and has loaded that package. The easiest way to verify that this might be the case would be:
Restart your computer,
Open R / RStudio,
Without loading any other packages, try once more to install.packages("Rcpp").
Let us know if you still see the same output on install.
Can you explain exactly what you mean here? If you have a call to e.g. setwd("~/") in a startup profile (e.g. .Rprofile or .Rprofile.site), then that could explain the behavior you're seeing. Why aren't you able to modify this file? Does this file contain the setwd() call that could explain why you're seeing this issue?