Browse Source

Books and more

tags/v1.5.0
boB Rudis 5 years ago
parent
commit
d523b8e3db
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 17
      RSwitch/Swift/Menu.swift
  2. 61
      RSwitch/Swift/MenuActions/BrowseMenuAction.swift
  3. 14
      guide/_site/index.html
  4. 17
      guide/index.Rmd

17
RSwitch/Swift/Menu.swift

@ -38,9 +38,19 @@ extension AppDelegate: NSMenuDelegate {
rstudioItem.isEnabled = self.rstudio_enabled
menu.addItem(rstudioItem)
// Add items to open variosu R for macOS pages
menu.addItem(NSMenuItem.separator())
// Add items to open various R for macOS pages
BrowseMenuAction.populateWebItems(menu: menu)
menu.addItem(NSMenuItem.separator())
// Add links to local copies of the R Manuals
BrowseMenuAction.populateLocalRManualsItems(menu: menu)
// Add links to free R online books
BrowseMenuAction.populateRBooksItems(menu: menu)
// Add running apps
populateRunningApps(menu: menu)
@ -49,11 +59,12 @@ extension AppDelegate: NSMenuDelegate {
// Add a Check for update
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: NSLocalizedString("Check for update…", comment: "Check for update item"), action: #selector(checkForUpdate), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "Check for update…", action: #selector(checkForUpdate), keyEquivalent: ""))
// Add an About item
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: NSLocalizedString("About RSwitch…", comment: "About menu item"), action: #selector(about), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "About RSwitch…", action: #selector(about), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "RSwitch Help…", action: #selector(rswitch_help), keyEquivalent: ""))
// Add a Quit item
menu.addItem(NSMenuItem.separator())

61
RSwitch/Swift/MenuActions/BrowseMenuAction.swift

@ -16,6 +16,10 @@ extension AppDelegate {
NSWorkspace.shared.open(url)
}
@objc func rswitch_help(_ sender: NSMenuItem) {
NSWorkspace.shared.open(URL(string: "https://rud.is/rswitch/guide/")!)
}
}
class BrowseMenuAction {
@ -31,19 +35,50 @@ class BrowseMenuAction {
BrowseMenuAction(title: "R-SIG-Mac Archives…", url: "https://stat.ethz.ch/pipermail/r-sig-mac/"),
BrowseMenuAction(title: "R-devel News…", url: "https://developer.r-project.org/blosxom.cgi/R-devel/NEWS"),
BrowseMenuAction(title: "R-Forge macOS Subversion…", url: "http://svn.rforge.net/osx/trunk/"),
BrowseMenuAction(title: "R Installation/Admin macOS Section…", url: "https://cran.rstudio.org/doc/manuals/R-admin.html#Installing-R-under-macOS"),
BrowseMenuAction(title: "R-Project R GUI Subversion…", url: "https://svn.r-project.org/R-packages/trunk/Mac-GUI/"),
BrowseMenuAction(title: "Bioconductor…", url: "https://www.bioconductor.org/")
]
private static let webItemsExt = [
BrowseMenuAction(title: "RStudio macOS Dailies…", url: "https://dailies.rstudio.com/rstudio/oss/mac/"),
BrowseMenuAction(title: "R Package Documentation (rdrr.io)…", url: "https://rdrr.io/"),
BrowseMenuAction(title: "Rseek…", url: "https://rseek.org"),
BrowseMenuAction(title: "R StackOverflow…", url: "https://stackoverflow.com/questions/tagged/r"),
BrowseMenuAction(title: "ROpenSci Discuss…", url: "https://discuss.ropensci.org/"),
BrowseMenuAction(title: "RStudio Community…", url: "https://community.rstudio.com/"),
BrowseMenuAction(title: "RStudio macOS Dailies…", url: "https://dailies.rstudio.com/rstudio/oss/mac/"),
BrowseMenuAction(title: "Unofficial R-O GitHub CRAN Mirror…", url: "https://github.com/cran"),
BrowseMenuAction(title: "XQuartz (X11 for macOS)…", url: "https://www.xquartz.org/"),
BrowseMenuAction(title: "Homebrew (macOS Package Manager)…", url: "https://brew.sh/"),
BrowseMenuAction(title: "Apple Developer Portal…", url: "https://developer.apple.com/")
]
private static let webItemsMan = [
BrowseMenuAction(title: "An Introduction to R…", url: "file:///Library/Frameworks/R.framework/Versions/3.6/Resources/doc/manual/R-intro.html"),
BrowseMenuAction(title: "R Data Import/Export…", url: "file:///Library/Frameworks/R.framework/Versions/3.6/Resources/doc/manual/R-data.html"),
BrowseMenuAction(title: "R Installation and Administration…", url: "file:///Library/Frameworks/R.framework/Versions/3.6/Resources/doc/manual/R-admin.html"),
BrowseMenuAction(title: "Writing R Extensions…", url: "file:///Library/Frameworks/R.framework/Versions/3.6/Resources/doc/manual/"),
BrowseMenuAction(title: "The R language definition…", url: "file:///Library/Frameworks/R.framework/Versions/3.6/Resources/doc/manual/R-exts.html"),
BrowseMenuAction(title: "R Internals…", url: "file:///Library/Frameworks/R.framework/Versions/3.6/Resources/doc/manual/R-ints.html")
]
private static let webItemsBook = [
BrowseMenuAction(title: "Advanced R…", url: "https://adv-r.hadley.nz/"),
BrowseMenuAction(title: "bookdown: Authoring Books and Technical Documents with R Markdown…", url: "https://bookdown.org/yihui/bookdown/"),
BrowseMenuAction(title: "Data Visualization: A practical introduction…", url: "https://socviz.co/"),
BrowseMenuAction(title: "Efficient R programming…", url: "https://csgillespie.github.io/efficientR/"),
BrowseMenuAction(title: "Forecasting: Principles and Practice…", url: "https://otexts.com/fpp2/"),
BrowseMenuAction(title: "Fundamentals of Data Visualization…", url: "https://serialmentor.com/dataviz/"),
BrowseMenuAction(title: "Geocomputation with R…", url: "https://geocompr.robinlovelace.net/"),
BrowseMenuAction(title: "ggplot2: Elegant Graphics for Data Analysis…", url: "https://ggplot2-book.org/"),
BrowseMenuAction(title: "Hands-On Programming with R…", url: "https://rstudio-education.github.io/hopr/"),
BrowseMenuAction(title: "R for Data Science…", url: "https://r4ds.had.co.nz"),
BrowseMenuAction(title: "R Gaphics Cookbook…", url: "https://r-graphics.org/"),
BrowseMenuAction(title: "R Markdown: The Definitive Guide…", url: "https://bookdown.org/yihui/rmarkdown/"),
BrowseMenuAction(title: "R Packages…", url: "http://r-pkgs.had.co.nz/"),
BrowseMenuAction(title: "Rcpp for Everyone…", url: "https://teuder.github.io/rcpp4everyone_en/"),
BrowseMenuAction(title: "Text Mining with R…", url: "https://www.tidytextmining.com/")
]
init(title: String, url: String, selector: String = "browseFromMenu", keyEquivalent: String = "") {
self.title = title
self.url = URL(string: url)!
@ -72,6 +107,28 @@ class BrowseMenuAction {
for item in webItemsExt { webSub.addItem(item.asMenuItem()) }
}
public static func populateLocalRManualsItems(menu : NSMenu) {
let manDropdown = NSMenuItem(title: "R Manuals (local)", action: nil, keyEquivalent: "")
let manSub = NSMenu()
menu.addItem(manDropdown)
menu.setSubmenu(manSub, for: manDropdown)
for item in webItemsMan { manSub.addItem(item.asMenuItem()) }
}
public static func populateRBooksItems(menu : NSMenu) {
let bookDropdown = NSMenuItem(title: "R Books", action: nil, keyEquivalent: "")
let bookSub = NSMenu()
menu.addItem(bookDropdown)
menu.setSubmenu(bookSub, for: bookDropdown)
for item in webItemsBook { bookSub.addItem(item.asMenuItem()) }
}
}

14
guide/_site/index.html

@ -372,6 +372,13 @@ div.tocify {
<p>RSwitch is a macOS menubar application that works on macOS 10.14+ and provides handy shortcuts for developing with R on macOS. You can download it from the <a href="https://rud.is/rswitch/">landing page</a> or contribute to the <a href="develop.html">development</a> of the application.</p>
<div id="credits" class="section level2">
<h2>Credits</h2>
<p>Many thanks to the following folks for their contributions to the project to help make RSwitch better for everyone:</p>
<ul>
<li><a href="https://github.com/guiastrennec">Benjamin Guiastrennec</a> for suggesting improvements to the documentation regarding how to use the installer packages from the <a href="https://mac.r-project.org/">R for macOS Developer’s Page</a> without clobbering existing R Framework installs.</li>
</ul>
</div>
<div id="basiccore-usage" class="section level2">
<h2>Basic/Core Usage</h2>
<p>After downloading and running the application a new menubar item will appear and the core menu will look something like this:</p>
@ -379,6 +386,7 @@ div.tocify {
<p>The initial and primary feature of the RSwitch app was to enable switching what your system considers to be the “current” version of R. To understand how that is “computed”, you should use the “R Frameworks Directory” option which opens up <code>/Library/Frameworks/R.framework/Versions</code> in the Finder so you can browse and manipulate the contents of that directory tree on your own.</p>
<pre class="r"><code>fs::dir_tree(path = &quot;/Library/Frameworks/R.framework/Versions&quot;, recurse = FALSE)</code></pre>
<pre><code>/Library/Frameworks/R.framework/Versions
├── 2.14
├── 3.5
├── 3.6
├── 3.7
@ -456,7 +464,11 @@ div.tocify {
<li><a href="https://mac.r-project.org/el-capitan/R-3.6-branch/R-3.6-branch-el-capitan-sa-x86_64.tar.gz">R 3.6</a> (current)</li>
<li><a href="https://mac.r-project.org/el-capitan/R-devel/R-devel-el-capitan-sa-x86_64.tar.gz">R 3.7</a> (devel)</li>
</ul>
<p>Once downloaded, you can fire up a terminal prompt, head to the root directory (i.e. <code>cd /</code>) and run <code>tar -xvzf path-to-thing-you-just-downloaded</code> to lay out the contents of the tarball onto the filesystem. (You can also use the <code>.pkg</code> versions if you prefer a clicky-installer wizard.)</p>
<p>Once downloaded, you can fire up a terminal prompt, head to the root directory (i.e. <code>cd /</code>) and run <code>tar -xvzf path-to-thing-you-just-downloaded</code> to lay out the contents of the tarball onto the filesystem. You can also use the <code>.pkg</code> versions if you prefer a clicky-installer wizard, but these installers will remove any previous versions of the framework (kinda defeating the purpose). You can still use the <code>.pkg</code> format by heading over to the command line and using <code>pkgutil --forget</code> to prevent said clobbering behavior (as noted in <a href="https://cran.rstudio.org/doc/manuals/R-admin.html#Uninstalling-under-macOS">Section 4.2</a> of <em>R Installation and Administration</em>. For example:</p>
<pre class="bash"><code>sudo pkgutil --forget org.r-project.R.el-capitan.fw.pkg \
--forget org.r-project.x86_64.tcltk.x11 \
--forget org.r-project.x86_64.texinfo \
--forget org.r-project.R.el-capitan.GUI.pkg</code></pre>
<p>Once you install one of these versions, <code>Current</code> gets manipulated to point to it. You can either <code>rm</code> the existing symbolic link and <code>ln -s</code> a new one or <em>just use RSwitch</em>!</p>
<p>Upon initial click, RSwitch figures out which versions of R you have installed and lets you switch them just by selecting the versioned menu item. When the change is made you get a handy notification letting you know the action performed successfully and which R version you changed to:</p>
<p><img src="r-change-notify.png" /></p>

17
guide/index.Rmd

@ -13,6 +13,12 @@ knitr::opts_chunk$set(
```
RSwitch is a macOS menubar application that works on macOS 10.14+ and provides handy shortcuts for developing with R on macOS. You can download it from the [landing page](https://rud.is/rswitch/) or contribute to the [development](develop.html) of the application.
## Credits
Many thanks to the following folks for their contributions to the project to help make RSwitch better for everyone:
- [Benjamin Guiastrennec](https://github.com/guiastrennec) for suggesting improvements to the documentation regarding how to use the installer packages from the [R for macOS Developer's Page](https://mac.r-project.org/) without clobbering existing R Framework installs.
## Basic/Core Usage
After downloading and running the application a new menubar item will appear and the core menu will look something like this:
@ -55,7 +61,14 @@ Here are direct `https` links to the tarballs:
- [R 3.6](https://mac.r-project.org/el-capitan/R-3.6-branch/R-3.6-branch-el-capitan-sa-x86_64.tar.gz) (current)
- [R 3.7](https://mac.r-project.org/el-capitan/R-devel/R-devel-el-capitan-sa-x86_64.tar.gz) (devel)
Once downloaded, you can fire up a terminal prompt, head to the root directory (i.e. `cd /`) and run `tar -xvzf path-to-thing-you-just-downloaded` to lay out the contents of the tarball onto the filesystem. (You can also use the `.pkg` versions if you prefer a clicky-installer wizard.)
Once downloaded, you can fire up a terminal prompt, head to the root directory (i.e. `cd /`) and run `tar -xvzf path-to-thing-you-just-downloaded` to lay out the contents of the tarball onto the filesystem. You can also use the `.pkg` versions if you prefer a clicky-installer wizard, but these installers will remove any previous versions of the framework (kinda defeating the purpose). You can still use the `.pkg` format by heading over to the command line and using `pkgutil --forget` to prevent said clobbering behavior (as noted in [Section 4.2](https://cran.rstudio.org/doc/manuals/R-admin.html#Uninstalling-under-macOS) of _R Installation and Administration_. For example:
```{bash eval=FALSE}
sudo pkgutil --forget org.r-project.R.el-capitan.fw.pkg \
--forget org.r-project.x86_64.tcltk.x11 \
--forget org.r-project.x86_64.texinfo \
--forget org.r-project.R.el-capitan.GUI.pkg
```
Once you install one of these versions, `Current` gets manipulated to point to it. You can either `rm` the existing symbolic link and `ln -s` a new one or _just use RSwitch_!
@ -135,5 +148,3 @@ If you're having trouble with RSwitch or have a feature request, head on over to

Loading…
Cancel
Save