I've been building an R package via an R project file (.Rproj) in R studio with the project file linked to my github. When I was working on it this morning, all was as it should be, but when I returned to it this afternoon, the .Rproj file had mysteriously vanished. All other files and folders associated with the package are where they should be (e.g., the "R" folder with the scripts for the package's functions, the DESCRIPTION file, the man folder, etc.) but the .Rproj file is gone. I have not deleted it and it is not in my trash can, nor does git have any record of it for some reason.
If I do a search for the file name in the windows search bar (I'm suing windows 7, btw) the file shows up and says that it is in the correct location, but if I click on it, I get an error message saying that the file has been moved or deleted. Similarly, if I try to navigate to where the file should be via "open project" in R, there is a greyed out ".Rproj.user" folder that I don't recall having seen before, but no project file.
I'm at my wits end for what is going on. The package on github appears to all still be correct (as do the files on my computer), but without being able to find or access the .Rproj file I can't easily edit the package and push the changes to github.
Does anyone have any idea what is going on or how to retrieve my package file? Since I have all the source files for it, I could always build a new project using the source files, but then I need that to link up to my github which is linked to a now non-existent project file, and everything becomes really messy and tedious quickly.
PS I have restarted both my computer and R. It didn't help.
You can probably just create a "new" project in the existing folder to generate a new .Rproj file.
The .Rproj file doesn't actually do that much. It mostly lets RStudio know that "this folder is the root directory of a project named X". Git keeps its own hidden files in the directory to track things (that RStudio will look for if it's a project).
If you haven't done this, I'd also recommend adding your .Rproj files to your .gitignore file - Rproj files are user-specific so shouldn't be tracked in version control. (If you used RStudio to create the git repo, this will be done automatically.)
Related
When I setwd using Rstudio IDE GUI, then I go to create a new file... the default working directory is not the current working directory. What is a better Workflow? Any .Rprofile commands to always save in the working directory?
pic 1
pic 2
As mentioned in the comments, using a project would certainly help. Projects will always set the working directory to the project root folder on opening. Additionally, previous commands and working environment is saved (if you want it to be), so you can get right back to where you were. This is especially useful if you are working on different assignments.
Additionally, you can use getwd() to get your current working directory. Remember that the RStudio file-browser doesn't update when you set your working directory in R.
Disclaimer: I am very new here.
I am trying to learn R via RStudio through a tutorial and very early have encountered an extremely frustrating issue: when I am trying to use the read.table function, the program consistently reads my files (written as "~/Desktop/R/FILENAME") as going through the path "C:/Users/Chris/Documents/Desktop/R/FILENAME". Note that the program is considering my Desktop folder to be through my documents folder, which is preventing me from reading any files. I have already set and re-set my working directory multiple times and even re-downloaded R and RStudio and I still encounter this error.
When I enter the entire file path instead of using the "~" shortcut, the program is successfully able to access the files, but I don't want to have to type out the full file path every single time I need to access a file.
Does anyone know how to fix this issue? Is there any further internal issue with how my computer is viewing the desktop in relation to my other files?
I've attached a pic.
Best,
Chris L.
The ~ will tell R to look in your default directory, which in Windows is your Documents folder, this is why you are getting this error. You can change the default directory in the RStudio settings or your R profile. It just depends on how you want to set up your project. For example:
Put all the files in the working directory (getwd() will tell you the working directory for the project). Then you can just call the files with the filename, and you will get tab completion (awesome!). You can change the working directory with setwd(), but remember to use the full path not just ~/XX. This might be the easiest for you if you want to minimise typing.
If you use a lot of scripts, or work on multiple computers or cross-platform, the above solution isn't quite as good. In this situation, you can keep all your files in a base directory, and then in your script use the file.path function to construct the paths:
base_dir <- 'C:/Desktop/R/'
read.table(file.path(base_dir, "FILENAME"))
I actually keep the base_dir assignemnt as a code snippet in RStudio, so I can easily insert it into scripts and know explicitly what is going on, as opposed to configuring it in RStudio or R profile. There is a conditional in the code snippet which detects the platform and assigns the directory correctly.
When R reports "cannot open the connection" it means either of two things:
The file does not exist at that location - you can verify whether the file is there by pasting the full path echoed back in the error message into windows file manager. Sometimes the error is as simple as an extra subdirectory. (This seems to be the problem with your current code - Windows Desktop is never nested in Documents).
If the file exists at the location, then R does not have permission to access the folder. This requires changing Windows folder permissions to grant R read and write permission to the folder.
In windows, if you launch RStudio from the folder you consider the "project workspace home", then all path references can use the dot as "relative to workspace home", e.g. "./data/inputfile.csv"
I am starting out on a project that I want to work with my friend in GitHub, so I created the meteor project locally and then added it to github. It added everything except .meteor directory. When my colleague cloned and got the project down since it is missing .meteor directory, he is unable to start working on it. How do we go about recreating .meteor file at another location or am I suppose to include .meteor file into github as well?
* Edit: Since it is brand new project, I asked him to recreate the project locally and copy .meteor directory from the newly created one and copy it to git file location and it worked. Now sure it is the right way though.
You should always check in your .meteor directory because it contains critical information like which meteor version to use and the required packages for the project.
I suspect you may have avoided doing so because of the huge database stored within that directory. Fear not - each meteor project comes with a .meteor/.gitignore which will avoid checking in your DB.
Basically I've binded two files, one of them works fine because it can be run from any directory on the computer, however the other one requires .DLL dependencies found in the folder that the binded file is in... However when you run the binded file (made in express) it extracts both the programs to the %temp% folder, so the program cannot find the .DLL dependencies and therefore doesn't work.
Is there anyway to make it extract the files into the directory it's being ran from?
I already answered this question here:
Iexpress - extraction path
It's actually a bit of a pain, since the current directory while IExpress is running an install program is something like %temp%\IXP000.TMP and there's very little clue where it was originally started without reverse traversing the "process tree".
Having said that, the extraction location (eg %temp%\IXP000.TMP) should contain both the executable and the .dll there, so the DLL should be easy for the executable to find. You might check the usual suspects: (1) is long file name (LFN) support enabled? and (2) is the .dll actually in the archive? More info on another answer here:
jar file not found iexpress
I'm using GIT and I note that if I just move the whole folder (or rename it) in windows, that it breaks all the paths. I then end up in an infinite loop of trying to quit Rstudio and Rstudio unable to find the file path to save (or not save).
Is there a way to move the location of the project folder while keeping it still intact?
Sorry, let me make this clearer.
Start Rstudio and create a version-controlled project (I'm using GIT)
Realize that you put the project in the wrong folder of your computer
Move the project to the new folder by (a) moving the Rstudio and GIT files to another location using windows explorer. (breaking all the links) or (b) start a new project in the 'correct' location. (losing the versions of your edits).
With RStudio closed, I moved the project folder (using Windows Explorer) to a new location. My RStudio project opened fine from there. I made an edit and pushed it to Github.
If you use the here package on Cran you won't have to update any links.
If you use GitHub Desktop, it will detect that the project has been moved and allow you to locate (set) it to a different folder.