What’s in RStudio’s Global Options Menu? The Top Options You May Not Know!

This is a long article–use the Table of Contents below to jump to a specific section if you’d like!

  1. General
  2. Code
  3. Console
  4. Appearance
  5. Pane Layout
  6. R Markdown
  7. Spelling
  8. Accessibility

In my new role as MAISRC’s Quantitative Ecologist, it’s my job to know as much as I can about the quantitative tools we ecologists and invasive species scientists use, R being chief among these!

I’ve been using R for more than a decade now, but even still, the more I learn about it, the more I realize I don’t know–R’s development is so rapid, it can be daunting to keep up! If you feel this way too, you may do what I did and join the R-bloggers listserv to receive daily or weekly digests on all things R.

In particular, I recently took a LinkedIn Learning course on R Shiny, and in that course, the instructor briefly poked around in the Global Options menu (under Tools in RStudio), and that touched off an epiphany for me–I didn’t really know many of the options that existed in the Global Options menu.

This seemed like a big knowledge gap! So, I decided to learn all the options in the Global Options menu (besides any really technical ones). As I had guessed, there are some very cool options! This article is a blow-by-blow of the ones that especially caught my attention, listed in order of the sections (starting with “General”) on the left-hand panel, from top to bottom. I will label each option with one of three labels:

  • πŸ†ALL: All RStudio users, even self-described “casual” ones, should check this option out! If you’re short on time, skim through just these by looking for red highlights, looking for the πŸ† symbol, or by searching for “ALL.”
  • βš–οΈSOME: Some users may find this feature interesting (I did, at least), but it’s probably not for everyone (or all workflows). If you want to come along on a “deep dive” with me, check for the blue highlights, look for the βš–οΈ symbol, or search for “SOME.”
  • πŸ”‹POWER: This looks like a powerful feature to me, but maybe its power is only unlocked best by self-styled “power users.” If you consider yourself an “R expert” already, skim through just these by looking for orange highlights, looking for the πŸ”‹ symbol, or by searching for “POWER.”

I’ll also include and highlight the option text, as it appears in the Global Options menu, so you can jump to a specific feature you’re curious about by using Find (Control+F on PCs)!

Two notes: While I’ll explain some R concepts as necessary, I will generally assume you understand the basics of R already. If not, you may consider learning R by taking a Carpentries workshop. Second, I wrote this article based on the “Prairie Trillium” release of RStudio for Windows, released on May 20th, 2022. I may not keep the article fully up to date (as I said, the R world moves fast!), so bear that in mind.

General

The highlights: Default working directory, .Rdata, History, Anti-Aliasing, .Last.value object, and the Help panel.

πŸ†ALL: Setting a default working directory upon startup. (Feature label: Default working directory (when not in a project): ) A working directory is a hard concept to explain. Basically, it’s a folder on your computer that an R session “lives in.” For example, if you go to upload a data set into R, R will look in your working directory for that data set file by default unless you specifically tell it to look somewhere else. R’s default working directory, the one that is created upon installation and the one it will open R sessions into by default, will be a somewhat arbitrary folder R creates for you. However, you can of course set your working directory to anywhere at any time (Session–>Set Working Directory in the RStudio options); a “chore” many R users are very familiar with! You can also use R Projects to make it easier to bounce between many folders you want to be working directories–I highly recommend learning to use R Projects if you don’t already!

If you don’t want to do this chore anymore, though, on the Basic tab, you can specify a default working directory so that your R always has a consistent “landing pad” it opens into, which might be especially great for those who aren’t (yet) using R projects and are keeping most of their R work in a single folder. For me, I tend to be an “R tinkerer,” so this lets me set my default directory to a folder devoted to tinkering (I use Projects to organize all the rest of my working directories).

πŸ†ALL: Stop asking me to save my workspace! (Feature label: Save workspace to .RData on exit) Your workspace/environment is another hard concept. Basically, it is a list of all the “words” in R’s working vocabulary during the current session, and specifically those you’ve “taught” it since you opened the current session. For example…

If I run the code above in my Console, a “word” called x will appear in my Environment pane to reflect the fact that I’ve taught R that whenever I say x now, I really mean 25. Creating words, or objects, like this is a lot of how we get anything done in R! However, when I close R, this will sort of “factory reset” R’s working vocabulary, so it’ll forget that x means 25, and I will have to “re-teach” it what x means next time I open R if I need to.

However, it doesn’t have to be this way. At any time, you can save the contents of your environment to a .Rdata file that you can reload later (by going to Session–> Save Workspace As and then using the same Session menu to reload that file again later). In the Basic tab, you can actually tell R it should always save your current environment every time you exit and then reload that same .Rdata file upon starting R again.

My current R Environment, full of all the “words” (Name column) I’ve taught R in this session, plus what they stand for (Value column).

This sounds good, right? It probably isn’t. It’s actually good in many ways that R starts “fresh” every time. If your environment gets full, it can get easy to mix up object names (what’s x mean versus x1?), to struggle to find new and unambiguous names for new objects (mean, MeanButNoReally, mean2.0, etc.), and to fill up your working memory, just to name a few issues! Remember, you can always have a script file filled with the code needed to remake objects you need, or you can save and load specific objects if remaking them is cumbersome.

So, it’s actually pretty annoying (to me, anyway) that RStudio will ask me, every time I quit, if I want to save my workspace into an .Rdata file. No, I don’t want that! Luckily, I can turn this prompt off on the Basic tab by toggling the drop-down menu here to “Never.” I can still save my workspaces manually at any time when I actually want to (which is very rare!).

βš–οΈSOME: Thin my history! (Feature label: Remove duplicate entries in history) The History pane shows you every line of code that’s been executed in the R Console (without all the error messages, outputs, graphics, etc. getting in the way) since you last cleared your History. It’s a very handy reference of your R activities; you can dig through it to find that code you used that one time (we’ve all been there!).

My current History pane, complete with all the code I’ve executed recently (including all the code that I’ve tried but that didn’t do what I wanted!) since I last cleared it–a handy reference!

There’s just one potential problem–by default, if at one point you ran the same exact line of code like 150 times (e.g. (mean(x)), all 150 lines would show up in the history and clog it up! On the Basic tab, you can toggle off duplicate lines in your history. Probably only handy for those who routinely consult their History pane (which I should really do more!), but unlikely to hurt anyone either!

πŸ”‹POWER: Anti-alias my graphics! (Feature label: Backend and Antialiasing) This might be a Windows vs. Mac thing–it’s unclear to me! Anyways, by default, it sounds as though RStudio doesn’t anti-alias your graphics, at least on Windows. Sort of by nature, computer graphics are “blocky” and “jagged” unless they are “aliased.” On the Graphics tab, you can use several approaches, implemented via various graphics packages (e.g., Cairo), to anti-alias your R graphics. On any platform, you can also adjust here how anti-aliasing works. The difference might be subtle for most users, but for some, the difference might be worth it!

βš–οΈSOME: Show my .Last.value object. (Feature label: Show .Last.value in environment listing) Maybe you’re like me: You just ran mean(x) and got back a result of 25.3458237593. “Darn–I really should have rounded that! But it took 5 minutes for that mean to calculate…”

On the Advanced tab, you can have R explicitly add the .Last.value object to your Environment panethis object stores a copy of the last result produced in the R Console, whether you saved it to an object or not. So, in the story above, I could just subsequently run round(.Last.value) and bail myself out! There may be other use cases, but that’s one I can imagine.

This option was a nice introduction to the .Last.value object for me; I didn’t know it existed before! Just note: The .Last.value is always present–it just isn’t explicitly listed in your environment unless you check this option.

πŸ†ALL: Help me read my Help! (Feature label: Help panel font size) You have options for changing the font sizes of most parts of the RStudio GUI (see the Appearance menu!!). By default, the font size of the Help pane is just 10. Oof! Unless you like eye strain, consider adjusting this font size on the Advanced tab.

My Help pane, with the font nicely increased to a comfortable size.

Code

The highlights: So many!!! This is the most loaded section of the Global Options menu by far… Code wrapping, commenting behavior, text surrounding, focus adjustments, code snippets, word highlighting, other highlighting, R opening behavior, file saving behavior, auto-completion behavior, and diagnostics behavior.

πŸ†ALL: Wrap up my code! (Feature label: Soft-wrap R source files) Code is traditionally displayed “literally,” with one line of code as one line of text, no matter how long it is! If it’s really long, you have to use a horizontal scroll bar to see the rest. But we humans don’t like to read like that! When you’re working in a file in the Source pane (such as a script file), you can have RStudio “soft-wrap” long lines of code so they “spill” visually (but not from a coding standpoint) onto the next line, much like sentences naturally do in a Word document (you can do this by going to Code –> Soft-Wrap Long Lines). This makes long lines much easier to read! However, conveniently, you can auto-enable this soft-wrapping feature on the Editing tab, so you don’t have to turn it on manually each time you open R.

A script file of mine, complete with soft-wrapping enabled–it’s a lifesaver!

βš–οΈSOME: Continue my comments. (Feature label: Continue comment when inserting new line) In R, you can insert a comment with the # symbol. R knows everything after a # on the same coding line is just for us humans to read and R should ignore it, so comments are a great way of leaving yourself notes about what your code is doing!

If you’re like me, some of your comments can get…lengthy. By default, if you are writing a comment in a Source pane file and hit enter to go to a new coding line, the next line will transition back to code, and you’d need to put another # to continue your comment. However, on the Editing tab, you can toggle this behavior and instead have the new line still be a comment.

This lets you keep on rolling with your long comments, but it means you will need to manually select a new line or delete the # if you want to transition back to code; some may find this feature annoying; others may love it. Keep in mind that soft-wrapping your long coding lines (which will include any comments!) might achieve the same visual effect without changing how R behaves.

πŸ†ALL: Surround text soundly. (Feature label: Surround selection on text insertion) RStudio has plenty of cool options that are already the default; here is an opportunity for me to point out one such feature! On the Editing tab, you can toggle what happens when you select text and then hit certain keys on your keyboard (specifically, keys with symbols that usually need to be used in pairs, such as ” ” and { }).

For example, imagine you typed Great.variable into your script file but you meant to type “Great.variable”…You have to manually add the missing quotes, right? Wrong! Just highlight that text (either using your mouse or by double-clicking it) and hit the ” key on your keyboard and RStudio will slap quotes around both sides of it for you! It’s awesome. On this tab, you can adjust this feature, but the default option is probably already what you want (i.e., fully enabling this feature for both quotes and brackets).

πŸ†ALL: (Feature labels: Highlight selected word and Highlight selected line) Relatedly, on the Display tab, you can toggle on word and line highlighting. You should keep (or turn) these both on! What do they do? Let’s say I double-clicked the object name year2 inside of a script file I am working in. These features would throw a box around not just the instance of year2 I just double-clicked to select but around every instance of the text string year2 in my script file (even inside of comments).

A script file of mine, with the first instance of the collab1Bslist variable name selected–note that all other instances of this same text string in my file are now also highlighted via boxes, and the line of the specific instance I selected is also highlighted with a box.

This is GREAT for seeing where in your code an object name is being referenced, which means it’s great for catching typos (i.e., when a spot in your code doesn’t highlight when you’d expect it to). It also helps you find all the regions of code that are dependent on a specific object you’ve created, e.g. You can also toggle whether the line containing the selected text string is highlighted, which helps you find it again if you have a large file and need visual assistance finding the specific instance you’ve selected.

βš–οΈSOME: Shifting one’s focus. (Feature label: Focus console after executing from source) If you’re like me, as you write prototype code in a script file, you also frequently run that code by flinging it to the Console, just to make sure it works the way you expect it to (which, for me, it often doesn’t!). By default, if you run code in the Console that you flung there from a file in your Source pane, the focus (where your cursor is active) will stay in the Source pane. So, if you want to run additional lines of code in the Console (e.g., to explore why your code didn’t do what you wanted), you will need to click or tab to bring R’s focus there. This *can* be annoying if you are like me and like to do “follow-up work” in the Console a lot.

If you do a lot of flipping back and forth between the Source and Console panes in your typical workflow, on the Editing tab, you can toggle it so that running code in the Console originating from the Source pane flips the focus to the Console instead by default.

πŸ”‹POWER: Code snippets! I’ll confess that this feature was totally new to me, but I don’t know how I have lived so long without it! Code snippets are short “keywords” that RStudio can recognize and automatically replace with a much longer block of code for you, like a coding “shortcut.”

For example, the basic guts of writing a function in R are: functionname = function(argument1, argument2,…) { operations; return(output) }. That’s a lot to type each time! With code snippets, I could instead type fun (if this is my keyword), then hit shift + tab (on Windows), and RStudio would insert all that junk above for me! While RStudio comes with a bunch of useful code snippets already, you can also build your own on the Editing tab. No more typing or copy-pasting large chunks of repetitive code again!

Just some of the built-in code snippets in RStudio (go to “Edit Snippets” at the bottom of the Editing tab to see the complete list).

βš–οΈSOME: Functions and rainbow brackets. (Feature labels: Highlight R function calls and Rainbow parentheses). Functions are incredibly important in R–they are essentially the verbs of the R language. Without using functions, you can’t get much done in R at all! Similarly, parentheses play a big role in R. They participate in math operations, function calls, and more.

Some really tricky errors arise when you try to use an object that isn’t a function as a function (e.g., mean1(x) when mean1 isn’t a function’s name) or vice versa. Other really tricky errors arise when your parentheses and other brackets aren’t “balanced” (i.e., they’re balanced when you have both a left and a right one paired properly), especially when you are nesting many operations inside of each other.

On the Display tab, you can toggle on function highlighting, which highlights all function names in your code in a distinct color (note–some RStudio editor themes also do this), so they are easier to “find” when reading your code. Similarly, you can also toggle on “rainbow brackets,” which colors each set of nested brackets in a single line of code a different color, so you can more easily see which left one goes with which right one and whether everyone has a “partner” in the right place.

Note how function names are in yellow here, and also note how there are two different colors for the pairs of parentheses in lines 44-45.

While these are potentially useful features, *some* users may feel they make their RStudio window look too technicolor for their liking!

βš–οΈSOME: Cursory behavior. (Feature label: Restore last cursor position when opening file) On the Saving tab, you can toggle how RStudio handles opening up a script file with respect to your cursor. If this toggle is off, your cursor will appear at the very beginning of a Source pane document when it opens, but you can instead have the cursor jump back to wherever it was the last time you saved your document by enabling this feature, so you can pick up where you left off. Most users will probably want to keep this feature on, but it’s nice to know you can turn it off too.

βš–οΈSOME: Save on source. (Feature label: Always save R scripts before sourcing) Here’s an example of a default feature you may actually want to turn off! When you “source” a file in RStudio, you essentially tell R to run every line of code in it all at once (as a “shortcut” to highlighting them and hitting run, e.g.). By default, RStudio will save your file before sourcing it (and it can also “source on save” too). However, I don’t necessarily like that it does this–if my code is iffy and I am using the source feature just to see if the whole thing works without errors, I *probably* don’t want to save my file before finding out that it’s a mess and that I’ve just overridden the version of the file that did work! So, thankfully, you can change this default behavior so that sourcing files doesn’t automatically save them on the Saving tab. Just don’t forget to save your files often manually instead!

πŸ†ALL: Taming wild idle files. (Feature labels: Automatically save when editor loses focus and When editor is idle) We’ve all been there: we’ve done hours of work in a script file only to walk away without remembering to save our progress…Uh oh! That’s just daring the universe to sabotage us, right?? Interestingly, RStudio allows you to turn on some protections against this scenario on the Saving tab:

As I said in the previous item, I don’t always want RStudio saving files before I’m “ready” (although I am a compulsive saver, so I may be different than many users)! But having it backup my files when they’ve sat idle for a while seems, at least, like a very good idea!

πŸ†ALL: Auto-completion! (Feature labels: Allow automatic completions in Console, Insert parentheses after function completions, Show help tooltip after function completions, Show help tooltip on cursor idle, and Show completions after characters entered) One of the most fantastic features of RStudio is auto-completion. If you start typing a word, and that word is in R’s “vocabulary,” you can hit the tab key and a tooltip (a little interactive menu) will pop up that contains all the “words” you might be trying to type and you can select the one you want and RStudio will insert it for you. If there’s only one word you could mean, hitting tab will just insert it. This can save you a ton of typing!

RStudio’s autocomplete features in action–I typed “for” and hit tab, bringing up all the potential words I *could* be trying to type. If I hover over one, I get another tooltip to the right explaining what that option does. If I click an option, RStudio will auto-complete my code to that option for me.

On the Completion tab, you can find all kinds of customizations for how auto-completion works. In particular, you can:

  • Turn on auto-completion for the Console too (by default, it only works in Source files; you might as well turn this on).
  • Toggle whether parentheses automatically appear alongside a completed function’s name (you want this!).
  • Toggle whether the help tooltip comes up whenever a function gets auto-completed (yes please!).
  • Whether idling the cursor will bring up the tooltip and how long this takes to happen.

All of these features are probably worth turning on, if you haven’t already!

You can also adjust how many characters you need to type, at a minimum, before auto-complete can take over. By default, it’s 3. However, I think you may want to think about changing it to 2; if you’re like me, I like being able to auto-complete “me” to “mean,” for example, since I use the mean function a lot. It’d also be nice to auto-complete if (using the if code snippet!) even though it’s only two characters long. However, if you instead find the auto-completion tooltip annoying, then you can make it less likely to come up here also–you can always bring it up manually by hitting tab.

πŸ†ALL: Coding diagnostics! (Feature labels: Enable diagnostics within R function calls, Check arguments to R function calls, Warn if variable used has no definition in scope, Warn if variable is defined but not used, and Provide R style diagnostics (e.g. whitespace)) Another fantastic set of features for RStudio are the diagnostics. If you are a regular RStudio user, you’ve seen these. Let’s say you forgot to type a comma somewhere–RStudio, by default, would put a red circle next to the line number in your script file where you missed that comma, underline the offending region with a red squiggle, and pop up a tooltip when you moused over the red circle with a message like “expected “,” after expression.”

RStudio’s diagnostics in action! Here, I missed a comma before the call to each(). RStudio’s diagnostics put a red squiggle underneath where it expects a comma to be, put a red circle with an X in the left gutter, and hovering over that red circle pops up a “helpful” tooltip explaining the issue.

Basically, diagnostics are “soft-running” your R code as you go to see if that code would trigger an error due to a number of common mistakes, such as missing a punctuation mark. This helps to prevent a lot of errors before they happen! On the Diagnostics tab, you can adjust a bunch of features related to how diagnostics work:

  • Diagnostics won’t necessarily check what you are doing inside of function calls, but this is a common place for errors, so you should probably let it do this if it can’t already.
  • By default, diagnostics won’t specifically check to see if you are providing inputs to function arguments correctly. For example, if you give an argument a number as an input but that argument needs to be a character, diagnostics won’t check for this kind of mistake by default. Since this is another common place for errors, you should probably let it do this.
  • By default, if you name a variable but never actually use it in your code (because maybe you typo-ed!), or if you insert a variable name but you haven’t actually created an object with that name yet, diagnostics won’t warn you by default that you are maybe mixing up or mis-typing your objects. Since these are incredibly common mistakes to make, you should probably allow diagnostics to check for these issues.

The only potential downside I can see to enabling these features, besides them yelling at you more often, is that they might cause R to use more memory (though I have no evidence that this is true)–so, maybe consider keeping them disabled if you are running into issues with your RStudio session going too slowly.

Less universally, you can also allow diagnostics to comment on your coding “style.” Hadley Wickham, R guru extraordinaire, has produced style guidelines for how R code “should” look; diagnostics can help enforce those guidelines for you, if you wish. Personally, I want my code to look how I want it to look, but it’s nice to know this feature exists!

Some users, especially power users, may find diagnostics distracting or annoying. If that’s you, you can turn diagnostics off entirely on this tab, but you probably shouldn’t. Instead, towards the bottom of this tab, you can toggle when and how the diagnostic messages pop up. For example, you can toggle it so that they only pop up when you save your document, so you have control over when they happen. Alternatively, you can have them pop up when you haven’t typed anything in a while (the default), but only after a certain period of time has passed. By default, this time period is really short (2 seconds, which is frankly way too short), but you could set it to be longer to reduce how often you are seeing diagnostic messages.

Console

The highlights: Console code colorizing and Console output limits.

βš–οΈSOME: Similar colorizing in the Console. (Feature label: Show syntax highlighting in console input). As I’ll discuss when we get to the Appearance menu, you can customize how your code looks in RStudio (and you should!). One limitation of these features, though, is that, by default, these changes only apply to the code shown in files in your Source pane. However, in the Console menu, you can change it so that the aesthetics of your code in your Source pane apply to unexecuted code in your Console pane also, in case that’s important to you!

A sense of what this looks like….

πŸ†ALL: Limit your output. (Feature label: Limit visible console output (requires restart) and Limit output line length to). Any experienced R user knows this particular pain: You just created an object called x that is really long (I mean, REALLY long…like…woah). You meant to type print(head(x)) to just look at a little slice of the object, but instead you typed just print(x) and the entire object printed in the Console! Now, your Console is completely clogged, and you can no longer see any of the other outputs you’ve received! Woe is you!

Luckily, RStudio offers you some protections against this mistake. In the Console menu, you can set it so that RStudio automatically limits how many lines of output can be displayed in the Console as a result of each executed operation. In my experience, limiting this to ~500 lines of code (or even much less!) will rarely cost you, and it could save you pain when you print an object you didn’t meant to print! This can be especially true if the object you accidentally printed is something incredibly complex (like a multi-dimensional array or a list of lists); printing one of these in its entirety can be so demanding it locks up R!

Appearance

The highlights. Literally everything!

πŸ†ALL: Customize your look! (Feature labels: RStudio theme, Zoom, Editor font, Editor font size, and Editor theme). While RStudio is the best thing to happen to R since, well…since ever, from my perspective!…by default, it ships looking a little…boring. Besides that, the default font can be hard to read (both because of its letter shapes and because of its size). And, because it defaults to a “day” palette instead of a “night” palette, it can also be very bright to look at for long periods.

On the Appearance menu, you can change all of these features to your heart’s content! If you haven’t already done so, I highly recommend spending a few minutes messing around with the features in the Appearance menu. Not only do I recommend turning up the default font size (and/or adjusting the Zoom), but I also recommend picking a “black” palette in the Editor theme to make R less bright to look at–my personal favorite is the “Vibrant Ink” theme, which is being features in many of the other pics in this post.

The themes don’t just look cool, though! They also help teach you to code better. Many of the themes will colorize different coding elements (characters, numbers, functions, logicals, brackets, etc.) in different colors. This can help make it easier and more intuitive to read your code and to spot errors (although it does take some getting used to!). Of course, if you don’t like this effect, you can select a theme that lacks these colorization effects, but I would only recommend that to power users.

Pane Layout

The highlights: Nothing in particular…

πŸ”‹POWER: Changing your layout. I don’t really have anything in particular to say about the Pane Layout menu other than, hey, there’s a Pane Layout menu! I didn’t know this was here, personally…

By default, RStudio comes with a (thoughtfully arranged, I think) set of four panes arranged in two rows and two columns. You can add (or remove) columns here, though! For example, if you are lucky enough to have a really big monitor, maybe 3 or 4 columns would work well for you.

A second possibility I can think of: I often find it annoying that I can either look at the Help pane or the Plots pane at one time (or either the History pane or the Environment pane, etc.). Shifting around which panes appear where, so that more panes I want to be examining a lot are on the screen simultaneously, seems useful!

The other opportunity I see here is the ability to adjust where specific elements of the RStudio GUI live. For example, maybe I want the Terminal or Jobs pane to be visible in place of the Console, if I am rarely using the Console in my current workflow.

R Markdown

The highlights: Chunks in outlines, output displaying, code execution, directories, visual editor, line numbers, and a citation editor.

Note: While I would argue that all regular R users should understand how to use R Markdown because the benefits are so immense, I recognize that some would view R Markdown as a “power user” feature. Feel free to skip this section if you want–however, as I said, R Markdown is an amazing tool that is worth learning (although there is definitely a learning curve!). Some material for learning R Markdown is available here.

πŸ†ALL: Soft-wrap R Markdown files. This toggle on the Basic tab does exactly what it says on the tin, so to speak–it turns on soft-wrapping for R Markdown files. You probably want that.

Soft-wrapping is available, even in R Markdown files.

βš–οΈSOME: What to show in the R Markdown Outline viewer. (Feature label: Show in document outline) The first option on the Basic tab turns on the document outline viewer by default (it’s always around but is hidden by default). This viewer is sort of an “interactive table of contents” for your document, allowing you to jump to specific sections of the file at will. By default, this will only populate based on section headers (those marked with #s), but you can change this to include both named and unnamed code chunks also, which I personally prefer.

R Markdown’s interactive Outline viewer (see top-right button and pane on the right). Note that I’ve enabled inclusion of even unnamed code chunks here.

βš–οΈSOME: Where to display (certain) Markdown outputs. (Feature label: Show output preview in) By default, when you run code in a code chunk, the output of that code will be displayed “inline.” That means, in practice, that it will be displayed right beneath that code chunk. Sometimes, this is convenient. Other times, it’s confusing! Students learning R often expect to see their code run in the Console, for example, even if they are running it from an R Markdown file. Also, if your code chunk is really long, you may have to scroll down a lot to actually see the output.

An image being rendered “inline” within an R Markdown file.

On the Basic tab, you can turn off inline evaluation–then, code run from an R Markdown file will produce outputs in the Console instead, like code in a regular script file would.

πŸ”‹POWER: Bulky previews (Feature label: Show equation and image previews) By default, if you generate an equation using LaTeX in a text region of an R Markdown file or create an image inside a code chunk and you run that chunk, you can get previews of what those images/equations will look like when your file is rendered. These can be bulky or get in the way, so if you find these previews annoying, you can toggle where they appear, or if they appear at all, on the Basic tab.

An equation being previewed within a tooltip within an R Markdown file in RStudio.

πŸ”‹POWER: Flexible directories when evaluating (Feature label: Evaluate chunks in directory). One of the more confusing aspects of R Markdown files, when you first start working with them, is remembering that they are kind of like their own little “universes,” complete with a working directory that may be exclusive to them. For example, by default, an R Markdown file will assume its working directory is the same folder as its corresponding file is currently in, even if that folder is different than the one currently serving as your working directory in your R session. If this sort of thing trips you up, it turns out you can change how your Markdown file assumes its working directory on the Basic tab, though you probably don’t want to…

πŸ†ALL: Turning on the visual editor. (Feature label: Use visual editor by default for new documents). In a recent update, RStudio added a visual editor to R Markdown files (in addition to the traditional “Source editor”)–admittedly, I hadn’t noticed! Instead of looking like a “code file,” your R Markdown file will look much more like a “knitted” file in “visual mode,” and you will be able to insert tables, lists, images, etc. as well as adjust font via buttons (see the top of the screenshot below) instead of via only code. As such, it might be an especially great way for beginners to get the hang of using R Markdown files without having to learn all the pesky Markdown code right away. It also makes it easier to see what your output file will look like without having to knit it first.

A taste of what the new Visual editor for R Markdown files looks like!

If you really like this feature, on the Visual tab, you can toggle the visual editor to be on by default.

βš–οΈSOME: Enabling line numbers in code chunks. (Feature label: Show line numbers in code blocks) By default, code chunks don’t have line numbers (probably to reduce “visual clutter”). But what if you have a long code chunk (say, 300 lines) in your report for some reason and, in the accompanying text, you want to draw attention to something that happens on line 147 of that chunk? Referencing line numbers may be helpful in that case. On the Visual tab, you can enable line numbers in code chunks (see the previous screenshot)–unless seeing these physically hurts you, I figure you might as well turn them on!

πŸ”‹POWER: Citation management! On the Citations tab, you can link a compatible citation manager (I recommend Zotero!) with your R Markdown, enabling one-button insertion of inline citations (and automatic generation of a bibliography) into your R Markdown file! More about this amazing feature can be found here. I have been told that, thanks to features like this, you can now write a whole scientific manuscript relatively painlessly entirely in an R Markdown file (with all the advantages in terms of reproducibility, version control, etc. that entails). This might be particularly fruitful if you need to include a lot of figures, equations, tables, etc. that you’re generating in R already because these will update right along with the data, text, and everything else. No more manually renumbering figures in the text when their order changes, e.g.!

The “Insert Citation” menu, available in the new R Markdown Visual editor by going to Insert–>Citation if you have a citation manager linked to your RStudio.

Spelling

The highlights: Custom dictionary and overlooking certain words.

πŸ†ALL: Customizing RStudio’s spellchecker. (Feature labels: Custom dictionaries, Ignore words in UPPERCASE/with numbers, and Use real time spell-checking). I guess I sort of appreciated that RStudio came with its own spellchecker, but I didn’t realize how easy it is to adjust its behavior! On the Spelling menu, you can adjust how RStudio’s spellchecker behaves in several useful ways:

  • You can add whole dictionaries, if you want–that way, R could check your spelling in Klingon or whatever! More practically, this gives you a way to introduce a pulse of new words (e.g., scientific names) you may want it to spellcheck (or ignore) without having to do so one by one.
  • You can edit your “user dictionary,” which are the words you’ve personally added to R’s dictionary by using the “Add to dictionary” option when you right-clicked a “misspelled” word in the editor.
  • You can tell R to ignore words written in all caps or that contain numbers, which would help R skip over variable/object names.
  • You can also turn the spellchecker off, if it’s just bugging you!
Who knew I had already added so many words to my personal RStudio dictionary? My favorite: “archvillain” (but spelled incorrectly!). I wonder what the use case for that had been…

Accessibility

I will close by just noting that there is a whole Accessibility menu containing several potentially useful features, including screen reading, toggling off UI animations, and highlighting the panel where the “focus” is, just to name a few!