{"id":342,"date":"2018-05-03T14:33:16","date_gmt":"2018-05-03T12:33:16","guid":{"rendered":"https:\/\/blogs.fu-berlin.de\/reseda\/?page_id=342"},"modified":"2019-07-19T14:31:05","modified_gmt":"2019-07-19T12:31:05","slug":"r-studio","status":"publish","type":"page","link":"https:\/\/blogs.fu-berlin.de\/reseda\/r-studio\/","title":{"rendered":"R-Studio"},"content":{"rendered":"<p>R is a programming language and software environment designed for statistical computing and graphic data output, which is very popular among data scientists. While R is operated purely by command line, there are several graphical user interfaces available, such as Rattle, R Commander, Deducer, RKWard, JGR, and R-Studio.<\/p>\n<p>In this online course we will use R-Studio as an <em>integrated development environments<\/em> (IDE). The default window layout of R-Studio is divided into four panes:<\/p>\n<p><a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/05\/laptop_rstudio.png\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/blogs.fu-berlin.de\/reseda\/files\/2018\/05\/laptop_rstudio.png\" \/><\/a><\/p>\n<div style=\"margin: -30px 0 20px 0;text-align: center\"><span style=\"color: #686868;font-size: small\">Default layout in R-Studio<\/span><\/div>\n<ul>\n<li><strong><span style=\"color: #6b9e1f\">1 Source Pane<\/span><\/strong>: for writing, saving and sending R code to the console. This pane does not exist by default when you start R-Studio. It appears only when you open at least one R-script via <strong>File &gt; New File &gt; R script<\/strong><\/li>\n<li><strong><span style=\"color: #6b9e1f\">2 Console Pane<\/span><\/strong>: Code you enter here is immediately processed by R. This pane is used for interactively testing code line-by-line before you copy your final code to the Source pane (1) above<\/li>\n<li><strong><span style=\"color: #6b9e1f\">3 Environment Pane<\/span><\/strong>: presents a list of information about all variables\/ objects in your current R-Studio session. This list contains their class, dimensions and names. There is a history of all processed lines accessible if you click the <strong>History<\/strong>-tab<\/li>\n<li><strong><span style=\"color: #6b9e1f\">4 Files Pane<\/span><\/strong>: contains several tabs for a file browser (<strong>Files<\/strong>), an essential help function (<strong>Help<\/strong>), the package manager (<strong>Packages<\/strong>), and viewer for plots (<strong>Plots<\/strong>) and interactive R output (<strong>Viewer<\/strong>)<\/li>\n<\/ul>\n<p>Although initially confusing, you will get used to each pane over time and quickly learn to switch between them to optimize your workflow when coding!<\/p>\n<p>R-Studio provides a variety of features that make life easier for you, e.g., color highlighting of syntax, code completion, find and replace functionality, import functions for data sets, and many more. Especially the <strong>Source pane<\/strong> allows to save sequences of commands for later re-use, enhancing reproducibility.<\/p>\n<p>&nbsp;<\/p>\n<h1>Execute your code<\/h1>\n<p>There are multiple ways to execute code in R-Studio. The simplest and most straight-forward way is to type your code directly in the <strong>Console pane<\/strong> and press <strong>enter key<\/strong> (or return key).<\/p>\n<p>In order to execute a line of code from the <strong>Source pane<\/strong>, place your cursor in this line and press <strong>Ctrl+Enter<\/strong> or use the <strong>Run <\/strong>toolbar button (top right corner of the <strong>Source pane<\/strong>). R-Studio automatically advances the cursor to the next line, enabling a execution line-by-line.<\/p>\n<p>You can execute multiple lines at once by selecting requested lines and pressing <strong>Ctrl+Enter<\/strong>. It is even possible to select parts of a line and execute only this selection. Press <strong>Ctrl+Shift+Enter<\/strong> or the <strong>Source <\/strong>toolbar button (top right corner of the <strong>Source pane<\/strong>) to execute the whole code inside your <strong>Source pane<\/strong>.<\/p>\n<p>If you want to make use of previously executed commands, you can use the keyboard&#8217;s up and down arrow keys when in Console pane to access the last entries, modify them if you want, and then press <strong>Enter <\/strong>again.<\/p>\n<p>&nbsp;<\/p>\n<h1>Get some help<\/h1>\n<p>R provides a comprehensive built-in help system. At the command prompt in the Console pane of R-Studio type any of the following in order to view descriptions of any operators, functions and objects:<\/p>\n<pre class=\"theme:amityreseda\">help.start()       # general help\r\nhelp(foo)          # help about function foo\r\n?foo               # help about function foo\r\napropos(\"foo\")     # list all functions having \"foo\" in their names\r\nexample(foo)       # show an example of function foo\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h1>Some useful shortcuts<\/h1>\n<p>There are some time saving shortcuts implemented to manage your R scripts:<\/p>\n<ul>\n<li><strong>Ctrl+Shift+n<\/strong> &#8211; create a new R document<\/li>\n<li><strong>Ctrl+o<\/strong> &#8211; open a existing file<\/li>\n<li><strong>Ctrl+s<\/strong> &#8211; save your currently active file in the <strong>Source Pane<\/strong><\/li>\n<li><strong>Ctrl+f<\/strong> &#8211; activate search\/ replace functionality within <strong>Source Pane<\/strong><\/li>\n<li><strong>Ctrl+Shift+c<\/strong> &#8211; comment\/ uncomment selected parts of your code (commented code with a <strong>#<\/strong> at the beginning of a line will not be executed)<\/li>\n<\/ul>\n<p>You can find all of those commands in the top toolbar of R-Studio as well.<\/p>\n<p>&nbsp;<\/p>\n<hr style=\"height: 4px;background-color: #6b9e1f\" \/>\n<div style=\"font-family: 'Noto Sans', sans-serif;line-height: 1.2;text-align: right\"><span style=\"font-size: 12px;color: #bfbfbf\"><strong><em>NEXT<\/em><\/strong><\/span><br \/>\n<a style=\"text-decoration: none\" href=\"https:\/\/blogs.fu-berlin.de\/reseda\/qgis\/\"><span style=\"font-size: 30px;color: #6b9e1f\"><strong><em>QGIS<\/em><\/strong><\/span><\/a><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>R is a programming language and software environment designed for statistical computing and graphic data output, which is very popular among data scientists. While R is operated purely by command line, there are several graphical user interfaces available, such as Rattle, R Commander, Deducer, RKWard, JGR, and R-Studio. In this online course we will use &hellip; <a href=\"https:\/\/blogs.fu-berlin.de\/reseda\/r-studio\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;R-Studio&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3237,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-342","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/users\/3237"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/comments?post=342"}],"version-history":[{"count":40,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/342\/revisions"}],"predecessor-version":[{"id":2931,"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/pages\/342\/revisions\/2931"}],"wp:attachment":[{"href":"https:\/\/blogs.fu-berlin.de\/reseda\/wp-json\/wp\/v2\/media?parent=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}