Rstudio Hidden Gems


#1

There’s a bunch of features not very well known but a game changer in Rstudio. Sometimes these gems don’t appear in documentation or in cheatsheets.

What’s your hidden gem ?

My first addition to the topic:

Add a timestamp to your code chunk just type ts and then Shift + Tab

# Wed Feb 07 10:07:33 2018 ------------------------------


#2

Reflow code with Ctrl + Shift + A


#3

Yeah, a good one. But maybe it’s not so hidden as it appears in Keyboard quick reference (Alt + Shift + K)

But one of my favourites anyway.

Thanks


#4

You can assign a shortcut for “Go To Next Chunk” in RMarkdown documents. I usually assign Ctrl + Down Arrow


#5

The cheatsheet link under the Help tab makes me happy. Its not hidden but even so it took me a while to “discover” it.


#6

ctrl + . to find files or function.


#7

Shift + Ctrl + r to insert a section heading or just a line to break up sections of code. Not a game changer really but saves you typing out a the # es


#8

You can clear the screen by typing:

cat('\f')

on your console.


#9

Ctrl l is even shorter for that (and l as in löschen is easy to remember if you happen to a German)


#10

Or…CTRL+L
= “Control-Limpiar” (clear screen) in Spanish :slight_smile:


#11

Nice! But why can’t they format the date correctly? :smiling_imp:


Feature Request: timestamp in ISO8601-ish format
#12

This would be awesome if there is a shortcut for this one:

Jump cursor to different section headings in Rmarkdown.

Please tell me it exists.


#13

In R Markdown documents, you can use Ctrl + PageUp and Ctrl + PageDown to quickly jump to the previous and next section (including chunks).

You can also pop up the scope tree list using Shift + Alt + J (Ctrl + Shift + Alt + J on macOS).

30%20AM


#14

Is there a hidden gem that allows me to type a comma outside of quotations?
When you type your first ", RStudio creates two marks right away, and your text goes in between. And so you type, let's say, c("foo"), and your cursor is currently between o and ". You need to place a comma after " to type the next argument, and my most common typo looks like this: c("foo," "bar")


Also, is there a hidden gem to indent / advance the code with TAB while inline? When I hit TAB inline, it's trying to bring up help or something, won't advance cursor.


#15

You can type the double quotes (") again when you are done and it will move you to the outside of the quotes so you can add the comma and keep typing. Typing the " after the last o in foo does not create another double quote, it only moves the cursor.


#16

You can create you own. Add it to Global options > code > snippets

snippet comma
"${0}",


#17

Reflow code with Ctrl + Shift + A

I wish this worked with pipe chains!


#18

Not sure if I would say it's hidden, (but I didn't see it for ages)

Find in Files
CTRL+SHIFT+F

Searches your whole code base for strings and then allows you to click to jump to them (like resharper for visual studio)


CTRL+ALT+SHIFT+M
Rename in scope
Ever had someone use a 1-letter variable name in 1500 lines of code? This lets you rename the actual variables called x not just replace each instance of x


#19

Just recently found out that you can View() a data frame or package function within your script by CTRL+Left-clicking on their name.


#20

Just recently found out that you can View() a data frame or package function within your script by CTRL+Left-clicking on their name.

I can't seem to figure out how to do this on Mac.... anyone?