I have a gWdigets GUI making a plot embedded in a ggraphics container. When I right-click on the plot, a menu "copy - save" appears, but when I save the file everything seems to work correctly but at the end there's no saved file.
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?
VS code recently added the ability to work with jupyter notebooks (.ipynb files), this is to say it renders them as notebooks and not the underlying text.
The problem I'm running into is I want to make some edits on the raw text rather than the "notebook" but I can't figure out how to show it as a text file the way any other editor would.
Is there a way to toggle between the views?
Disable automatically opening *.ipynb files in Notebook Editor
To make sure the Jupyter notebooks don't open in the Notebook Editor automatically, make sure to disable this settings. (Command Palette -> Settings)
OR
In the User or Workspace settings.json, add the following the root json - "jupyter.useNotebookEditor": false
To toggle between the Notebook Editor and Raw Text Mode Editing
There is an option/command called Reopen Editor with..., which will provide you options to open the *.ipynb file in text mode.
You trigger this by performing a Right Click on the Editor Tab (Editor Title Bar) or Command Palette -> Reopen Editor with...
PS: I have the Jupyter extension (v2020.12.414227025)
Open: File > Preferences > Settings
Search ipynb and deselect the following:
Other answers didn't work for me recently. I found no "use notebook editor" option under preferences, perhaps vs code has reorganized recently. Instead I found the following solution. Right click on an *.ipynb file tab to get the context menu, and click "Reopen Editor With..." as pictured below.
Then on the following popup click "configure default editor for .ipynb", and then click on the text editor as seen below:
And viola. The default settings have been changed.
I think the fastest way is to rename the file.
Just press F2 (or return for mac) while selecting the file in the vscode explorer, then rename from my-notebook.ipynb to my-notebook.json, because jupyter ipynb files are regular json files
Create .json file and paste the notebook json in there, save the file and then rename the extension to .ipynb and it will open in the jupyter editor
(Similar to aquirdturtle's answer)
What about
On the left side explorer
Right Click on file -> Open With -> Text Editor
Set the setting
"files.associations": {
"*.ipynb": "text"
}
Or try click on the Status Bar field that shows the Language Mode of the file in the lower right.
Use the command: Change Language Mode
I have created my AppleScript, tested it, saved it as an .app and it works.
Now, how do I set a custom icon for it?
I have done a bit of googling and tried a few different things but cannot get it to work. The app is mainly for me and maybe some people I know to make workflows easier so having a nice little icon makes a huge difference.
Can anyone help with this please?
Basically you need an .icns icon file.
Open your application with right-click > Show Package Contents
Navigate to Contents > Resources
Delete applet.icns
Drag the custom icon file into the Resources folder
Rename the icon file in Resources to applet.icns
To update the icon appearance open and re-save the applet in Script Editor.
This is how I do it:
In Finder, select your icon file.
Get Info (CMD-I) on the file.
Click the icon in the top left corner of the Get Info window.
Copy it via CMD-C.
Now Get Info on your AppleScript file.
Click the icon in the top left corner of the Get Info window.
Paste the icon using CMD-V.
The AppleScript icon should be replaced by the icon copied from the icon file.
A screen recording demonstrating this process can be viewed at this answer from AskDifferent.
Just building into #pipwerks answers: You can also use Drag&Drop!
(Optional) Create your icon online from any image on https://iconverticons.com/online/ and download de .icns file for your icon.
Get Info (CMD-I) on you AppleScript file.
Now Drag&Drop your .icns file into the small icon in the top left corner.
It works and now it's ready to add it to the dock or wherever you want.
On newer systems if the above methods do not work there is another solution.
In Script Editor, after opening our script (.app), choose View -> Show Bundle Contents from the menu (or press cmd +0).
In the panel that will expand on the right (Bundle Info) in the Resources section, right-click the applet.icns file and select delete from the drop-down menu.
Our new icon file with the same name applet.icns drag and drop into the window Resources where you just deleted it.
Save application and voila :-D
Here's another way on newer systems, I'm using macOS 12.1.
Open the new icon image file in Preview and choose File > Export...
Hold down the Option key while selecting "Format" and see a whole bunch of new choices including ICNS.
Save it, drop it in your Resources folder, and you're good to go.
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.
I have a shiny app that renders a plot using ggplot2. In fact, the browser's download image button works too (right click). And, when I download the image it does and displays when I open the file.
Only problem is that the file name to which it downloads is simply called 'untitled'. I want to make the file download to a name. But, I don't want to use the 'download image/plot' button. All examples I see show this option. Want to use built-in browser capability.
Any ideas?
If you don't want to use a button, you could use ggsave inside the function that creates the plot: http://docs.ggplot2.org/0.9.2.1/ggsave.html