Rstudio Hidden Gems

I also cannot do that in Mac.

However I use my own rstudio addon to View() anything in script, usually I assign ctrl+D to that feature so I just ctrl+D on anything in script (it can be an expression).

This is by far the most frequently used feature of my addon.

On macOS, you should be able to use Cmd + Click (as opposed to Ctrl + Click) to open an object in the Data Viewer.

1 Like

I tested again and found it works but with some limitations:

  • it only work with data.frame, while View() can also work on list. I found the list viewer to be one of the most useful new feature from RStudio.
  • if there is a function at same name, it will open the function definition instead of variable. In data.table usage it's common to name dt as the variable, which will lead to dt function with this.
  • it's single click so you cannot select arbitrary expression ( I often select a portion of a line to View it).

I knew you can press F2 to open function definition(didn't know it now work on data.frame), this seemed to be exactly same with F2.

For what it's worth, the limitation that only data.frame objects can be viewed will be lifted in RStudio v1.2.

Your other points re: choosing a data object vs. a function, and viewing an arbitrary expression, are good ones -- would you be willing to file this as a feature request, at https://github.com/rstudio/rstudio/issues?

3 Likes

What an excellent list of tricks! Ctrl + shift + f and Ctrl + i are probably what I use the most.

The Alt trick to edit several lines at once blew my mind a few months ago. I tweeted about it (with a gif to demonstrate) here: https://twitter.com/i_steves/status/995394452821721088

5 Likes

I just filed the feature request here. I'd love to see it implemented in RStudio!

1 Like

Good to know! But, really, why a date that needs lubridate?

#2018-11-28 17:29 -------------------------------------------------------

ctrl + PageDown/Up jumps from one heading/chunk to the next?

3 Likes

I think that you can use lubridate or whatever format you want, as ts seems to be a snippet:

# From snippets window, available from Preferenes -> Code -> Edit snippets:
> snippet ts
	`r paste("#", date(), "------------------------------\n")`

Note the use of date(), I believe you can put whatever code you want there to generate the date