Top 5 Tips for RStudio Workbench and Desktop

[This article was first published on r – Appsilon | End­ to­ End Data Science Solutions, 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.

RStudio Workbench

RStudio recently announced the renaming of RStudio Server Pro to RStudio Workbench. Along with the relabel, some updates and new features were added. In this blog, we will discuss our 5 favorite tips for more efficient use of RStudio Workbench (also applicable for RStudio Desktop).

  • R
  • RStudio

    R

    R is a free software environment for statistical computing and graphics. It compiles and runs on a variety of UNIX platforms, Windows, and MacOS. It supports a wide range of packages that implement a variety of algorithms and tools for data scientists, data analysts, data engineers, statisticians, and business analysts.

    RStudio

    RStudio is a free and open-source IDE (Integrated Development Environment) for R. RStudio’s GUI (Graphical User Interface) makes it easy for a coder to navigate various parts of a project like viewing graphs, data tables, R code, and output simultaneously. The developer can manage git, database connections, files and directories, R packages, and more from within RStudio. With RStudio, one can also publish a shiny dashboard to the web on shinyapps or RStudio Connect. While the IDE is already intuitive and easy to use, becoming an expert in RStudio will greatly improve the speed and efficiency of your software development. Here, we look at five tips that will make your day-to-day development tasks more efficient.

    Appsilon is a proud RStudio Full Service Partner.
    Discover how we can help you succeed with R and RStudio. 

    1) Shortcuts

    In day-to-day programming, we repeatedly execute several actions (e.g., restarting the R session, creating a function, or running an R Shiny application). While there are GUI elements to perform these tasks, it can be more convenient and efficient to use shortcuts. Here are some of the most useful shortcuts on RStudio:

     

    Check out our blog more RStudio Shortcuts and Tips

     

    Usage

    Apart from adding comments, commenting and uncommenting shortcuts can be used as a quick way to turn on and turn off parts of the code while experimenting and iterating with the code.

    The various panels can be navigated with the Ctrl + shortcuts.
    Quickly add documents, and then when the save all documents shortcut is pressed, RStudio will prompt the user to save the new file with a name.

    Running the whole document can also be used as Run App for R Shiny Apps when the Run App icon is active.

    2) Multi-Column View

    RStudio has recently introduced an awesome feature. We can now have 3 additional columns (for a total of 5) to the layout of RStudio. This is helpful as we often work with multiple documents in the project. This way, we can have more than one document open, keeping all other views intact.

    RStudio IDE column view

    RStudio with 5 columns

    To add more columns to RStudio follow these steps:

        1. Click on “Tools” from the menu bar at the top
        2. In the dropdown, click on “Global Options”
        3. On the pop-up, click on “Pane Layout” tab of the left sidebar
        4. Now “Add Columns” or “Remove Columns” as needed

    3) Finding Functions & Variables

    Often, we need to find where functions or variables are used. Vice-versa, we look for function and variable definitions across the entire project. RStudio has the combined ability to search within a file as well as across all files in the working directory. It is also possible to quickly open a file in the working directory by searching for filename or function name. This helps us quickly track a function or variable across multiple documents in the project. Combine the three shortcuts below to quickly trace a function or variable.

     

    4) Multi-Cursor Editing

    RStudio natively supports multi-cursor functionality. That means it is possible to have multiple cursors concurrently in different parts of the code and edit them all simultaneously. There are shortcuts for faster editing using this functionality. For example, when a variable change is needed but within the scope of the function or file. And a change is needed to all names of the variable within that function, including in the argument list. This is possible with the second shortcut below.

    5 Tips for Writing Clean R Code

     

    Ctrl/Cmd + Click/Click & Drag

    Click and drag cursor editing

    Ctrl/Cmd + Alt/Option + Shift + M

    Ctrl+alt+shift+M

    These are very useful in code refactoring, code cleanup, tracking variables within a scope, finding & replacing variables in the scope, adding repetitive code snippets quickly, etc.

    5) Investigate Function Source Code & Documentation

    In Microsoft Excel and Google Sheets, you can press F2 to show the formula and cells involved. Similarly, in RStudio, by pressing F2 or on mac fn + F2, it is possible to dig into the source code of any function. This action permits a quick investigation of the source code of any function in our R code.

    Place the cursor on the function name where used. Pressing F2 (fn + F2 in mac) will open up the source code of that function. To quickly open the function documentation, we can press F1 (fn + F1 in mac), and the built-in documentation for the function will open up in the “Help” pane at the bottom right of the screen.

     

    Conclusion

    These useful functionalities are the little bonuses that make RStudio a great tool to pre-process and analyze data – and build algorithms, dashboards, and applications. They make it simple to manage git repositories, packages, and code, including functions and variables. It will also help in developing and iterating faster and building more durable applications and algorithms.

    Let’s Build Something Beautiful Together

    Appsilon provides innovative data analyticsmachine learning, and managed services solutions for Fortune 500 companies, NGOs, and non-profit organizations. We deliver the world’s most advanced R Shiny applications, with a unique ability to rapidly develop and scale enterprise Shiny dashboards. Our proprietary machine learning frameworks allow us to deliver Computer VisionNLP, and fraud detection prototypes in as little as one week.

    Discover our growing list of open-source R Shiny packages at shiny.tools. If you find our open-source packages useful, please consider dropping a star on your favorites at our Github. It helps let us know we’re on the right track. And if you have any comments or suggestions, swing by our feedback threads like the discussion at our new shiny.fluent package or submit a pull request. We value the R community’s input.

    world class enterprise Shiny dashboards

Article Top 5 Tips for RStudio Workbench and Desktop comes from Appsilon | End­ to­ End Data Science Solutions.

To leave a comment for the author, please follow the link and comment on their blog: r – Appsilon | End­ to­ End Data Science Solutions.

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)