Is there any interaction from R to RStudio possible?
I would really like, for example, to set the RStudio files pane directory from the R console, like setFilesPane(getwd()) or such. I haven't found anything though.
Edit: To clarify: In RStudio there is a "files pane" (bottom right)
This can be navigated like any file explorer. However I would like to set the files pane directory (the directory whose contents are shown in the files pane) from my R code instead of having to navigate to my project folder by hand every time. Is there any way to do this?
Was answered by #docendodiscimus:
click the arrow at the top of the console pane (bottom left)
Thanks!
rstudioapi::filesPaneNavigate() ought to do what you're looking for.
Related
For some reason, I am unable to set or change my working directory in my R-code itself. I'll include a line such as:
setwd("~/Documents/BeaverProject/HOBOData/Beav")
But it will be followed with an error:
Error in setwd("~/Documents/BeaverProject/HOBOData/Beav") :
cannot change working directory
However, if I go to the file browser tab in the bottom right corner, and click "(gear icon) More", it provides an option to "Set as Working Directory" which I can use to change the working directory to the desired file folder.
While this works, it means that I can't just sit back and allow my code sequence to run because I have to manually change the working directory at every point in the code where it needs to.
Any suggestions?
I'm having trouble soft wrapping .R source files in the text editor in Rstudio Version 1.4.1717. I have tried to follow advice given online but it dosn't seem to change anything on my screen. It seems it should be fairly simple using the advice here:
Disable horizontal scroll in the Source of RStudio
and here:
wrap code in R Studio text editor
I have tried various things like ticking and unticking "soft wrap R source files check box", selecting all text in the text editor before re-trying, closing and restarting Rstudio etc...but still doesn't seem to work. I'm not sure if I'm missing something really obvious?!
Update: I managed to get it working if I start a new file (File > New File > R script). Please see here:
R studio image
However, this does not seem to work for R scripts that I had already created. The bottom right of the source window, does indeed say "R Script".
Update 2
I managed to get this working if I copy pasted the entire R script to a new file ((File > New File > R script), as opposed to re-saving the current file as a newer version (using File > Save As...")
When I went to save the file, a pop-up box appeared which asked me "Choose Encoding" for which I selected the default. I wonder if the previous file had a different encoding which meant the text wrapping could not work properly? Strangely, much earlier versions of the file did NOT have any problems when when using the wrap text functionality. So it seems that something happened to one of the recent versions that is causing the issue.
Do you remember to click apply before the ok button after checking the box?
You need not restart RStudio to get the change effected.
I have a project with multiple scripts I know how to clear the console and how to use rm to remove the variables I create. I have tried using the x on the upper right of the scrip.R tabs I want to delete and then saving the project after deletion. When I re-open the project those scripts I deleted are back on again.
thanks for any help. tried the RStudio help and R documentation as well as the search here
If by scripts you mean files in your RStudio project directory, you can delete them on the file tab of the bottom right pane. Select the file and click the delete button.
The x on the upper right just closes the editing session for that file.
If by scripts you mean R functions, they can be deleted like any other variable.
rm(functionName)
or
rm(list=ls(all=TRUE))
You can delete a script by clicking the white box next to it in the project environment and then clicking the delete button in that same environment.
You can also delete by going into file explorer where your project is located on your machine and delete just like any other file.
Is there any way to open the default Windows Images folder with the fileInput component?
Right now it is opening "My Computer" and I don't want this behaviour.
Yes, I believe this is possible. However, it involves changing your global directory in R. This process is good if you're only going to be using the one directory for a while. To do this:
Go into RStudio
Select "Tools" -> "Global Options.."
You should see something like the image above, then you can select "Browse..." in the red box which will bring up a folder selector, from here you can set your new permanent working directory
Once you've selected your folder, hit "Apply" and then "Ok"
After you've done this when you open your shinyApp with a fileInput the default should be the global path you just set.
For some reason the side bar on Sublime Text 3 is just displaying the folder named Template. The strange thing is that this folder is already deleted and regardless of that, the folder Template should not be displayed when I open Sublime in for example my Dropbox folder. No matter where in Ubuntu I open Sublime (from command line or Dash) it will open with that folder named Template in the sidebar. Template will have the arrow next to it indicating I can expand its contents or hide them. When I press it I see the arrow go from the right to to down position no folder contents show, nothing happens.
Also nothing happens when I go Project > Refresh Folders.
This problem happened around the time I was trying to add a new server using SFTP. Not certain if that had anything to do with it.
Any ideas whats happening here?
If it is a top level folder, you need to edit the project itself. You may right click on the folder in the side bar, and select "Remove from Project". Alternatively, you can edit the file itself by going to Project -> Edit Project. The top level folders are defined as a list of objects. Remove the entry you want from there, and it will no longer appear in the sidebar. You can write a plugin to clean up a project for you if you find yourself removing items frequently.