December ’16 RStudio Tips and Tricks

[This article was first published on RStudio, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

by Sean Lopp

Here is this month’s collection of RStudio Tips and Tricks. Thank you to those who responded to last month’s post; many of your tips are included below! Be sure to subscribe to @rstudiotips on Twitter for more.

This month’s tips fall into two categories: Keyboard Shortcuts and Easier R Markdown

Keyboard Shortcuts

The RStudio IDE is built upon “hooks”. Hooks are actions that the IDE can take. For instance, there is a hook to create a new file. Most users interact with hooks with point-and-click interactions. (RStudio toolbar -> new file or File -> New File). But, there is an alternative! All of these hooks have been surfaced to end users and can be bound to a keyboard shortcut. (Some of these actions are “secret” – they aren’t exposed through point-and-click options.)

Custom Keyboard Shortcuts

To view the complete list of actions, the current keybindings, and to customize keybindings, go to: Tools -> Modify Keyboard Shortcuts.

Code Chunk Navigation

Define shortcuts for code chunk navigation using the previous tip. For example, Alt+Cmd+Down for Next Chunk and Alt+Cmd+Up for Previous Chunk.

Assignment Operator

Use Alt+- (press Alt at the same time as pressing -). This adds the assignment operator and spacing.

Pipe Operator

Use Cmd+Shift+m (for Mac) or Ctrl+Shift+m (for Windows). This adds the pipe operator %>% and spacing.

Easier R Markdown

R Markdown Options

R Markdown output formats include arguments specified in the YAML header. Don’t worry about remembering all of the key-value pairs; in RStudio, you can access and change the most common through a user-interface:

Spell Checker

Use the built-in spell checker when writing a R Markdown document. (Code chunks are automatically ignored.)

SQL Code Chunks

Execute SQL queries against database connections directly in R Markdown chunks.

R Markdown Websites

Are you building a website with R Markdown? Any RStudio project with an R Markdown website will include a Build Website option in the build pane.

What’s your favorite RStudio Tip?

To leave a comment for the author, please follow the link and comment on their blog: RStudio.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)