{"id":6590,"date":"2017-06-24T04:00:29","date_gmt":"2017-06-24T04:00:29","guid":{"rendered":"https:\/\/assignment.essayshark.com\/blog\/?p=6590"},"modified":"2023-01-02T10:08:45","modified_gmt":"2023-01-02T10:08:45","slug":"r-programming-examples-2","status":"publish","type":"post","link":"https:\/\/assignmentshark.com\/blog\/r-programming-examples-2\/","title":{"rendered":"R Programming Examples"},"content":{"rendered":"<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li><strong>Code editing and executing<\/strong><br \/>\n<h2>General information<\/h2>\n<p>The RStudio code editor includes a number of options for productive work \u2013 in particular, code highlighting, code completion, simultaneous editing of multiple files, and searching and replacing certain parts of the code.<!--more--><\/p>\n<h2>File management<\/h2>\n<p>RStudio supports syntax highlighting and other specialized options for working with the code in the following file types:<\/p>\n<ul>\n<li>R-scripts<\/li>\n<li>Sweave documents<\/li>\n<li>TeX documents<\/li>\n<\/ul>\n<p>To create a new file, use the menu File -&gt; New:<br \/>\n<a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6592\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-1.png\" alt=\"\" width=\"533\" height=\"188\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-1.png 533w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-1-300x106.png 300w\" sizes=\"auto, (max-width: 533px) 100vw, 533px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>To open an existing file, use the menu File -&gt; Open or Open Recent. If you open multiple files at the same time, the rapid transition from one document to another is performed using the corresponding tabs at the top of the code editor window. To navigate between a large number of open files, there is the &gt;&gt; icon at the top right of the window of the editor. You can also use the menu View -&gt; Switch to.<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6602\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-2.png\" alt=\"\" width=\"531\" height=\"214\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-2.png 531w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-2-300x121.png 300w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/a><\/p>\n<h2>Code completion<\/h2>\n<p>As noted above in the description of work with the console, RStudio supports automatic code completion using the Tab key. For example, if the workspace has an object called pollResults, you can type on the keyboard poll is, press Tab, and RStudio automatically completes the name of the object.<\/p>\n<h2>Search and replace the parts of the code<\/h2>\n<p>RStudio Editor has the ability to find and replace the necessary parts of the code. For this you need to use the keyboard shortcut Ctrl + F or the Edit menu -&gt; Find and Replace. At the top of the editor window, there is a button in the form of a magnifying glass \u2013 pressing it also leads to the discovery of the dialog box in which you specify your search.<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6604\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-3.png\" alt=\"\" width=\"527\" height=\"225\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-3.png 527w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-3-300x128.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/a><\/p>\n<h2>Automatic functions creation<\/h2>\n<p>RStudio Editor can analyze the selected part of the text and automatically convert it into a function for later reuse. All the &#8220;free&#8221; variables in the selected code (that is, objects that are referenced but are not created in isolation) will then be converted into function arguments:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6606\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-4.png\" alt=\"\" width=\"527\" height=\"203\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-4.png 527w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-4-300x116.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/a><\/p>\n<h2>Code comments<\/h2>\n<p>To comment on the selected parts of the code (or to remove comments) use the menu item Edit -&gt; Comment \/ Uncomment Lines.<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6610\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-5.png\" alt=\"\" width=\"525\" height=\"223\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-5.png 525w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-5-300x127.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/a><\/p>\n<h2>Code execution<\/h2>\n<p>Studio supports execution of code directly from the Editor window. To execute the current line of the code, you can use the keyboard shortcut Ctrl + Enter or click Run Line (s):<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6614\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-6.png\" alt=\"\" width=\"527\" height=\"220\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-6.png 527w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-6-300x125.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/a><\/p>\n<p>After the code execution, the cursor will automatically move to the next line. This mechanism makes it possible to step through the code.<\/p>\n<p>There are two ways to run multiple lines of code:<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Select the required line and press the keys Ctrl + Enter;<\/li>\n<li>Press Ctrl + Shift + Enter to execute all lines in the script.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h2>Hotkeys<\/h2>\n<ol>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Ctrl + Shift + N &#8211; Create a new document<\/li>\n<li>Ctrl + O &#8211; open the document<\/li>\n<li>Ctrl + S &#8211; save the document<\/li>\n<li>Ctrl + 1 &#8211; move the cursor to the Code Editor<\/li>\n<li>Ctrl + 2 &#8211; move the cursor to the command line console<\/li>\n<\/ul>\n<\/li>\n<li><strong>2. Navigation in the code<\/strong><br \/>\n<h2>General information<\/h2>\n<p>RStudio includes a number of options that provide fast navigation in the code. The study of these options may lead to a significant increase in efficiency, as well as a better understanding of the code written by others.<\/p>\n<h2>Transition to File or function<\/h2>\n<p>If you know the file name of the script or the function name, you can quickly locate them using the search box Go to File \/ Function (Go to File \/ Options) in the main toolbar:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6616\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-7.png\" alt=\"\" width=\"666\" height=\"220\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-7.png 666w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-7-300x99.png 300w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/a><\/p>\n<p>The option &#8220;Go to File \/ Function&#8221; works by continuous indexing of the created code.<\/p>\n<h2>Transition to function definition<\/h2>\n<p>Due to the continuously implemented indexing of the code (see above), RStudio can also help you to find the definition of any function. To navigate to the code of the function, move the cursor to its name, and then click Go to Function Definition:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6618\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-8.png\" alt=\"\" width=\"663\" height=\"186\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-8.png 663w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-8-300x84.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/a><\/p>\n<p>Going to the definition of the functions can also be done in the following ways:<\/p>\n<ul>\n<li>Using F2.<\/li>\n<li>Using Ctrl + click on the function name.<\/li>\n<li>Using the Code Editor or console.<\/li>\n<\/ul>\n<h2>Navigation in the script<\/h2>\n<p>There are several ways to navigate through the code stored in a separate script file:<\/p>\n<p>The above option &#8220;Go to File \/ Function&#8221; Allows you to search within the file with the script.<\/p>\n<p>The command Jump to Line (Go to line) is designed to move to a specific line of the script.<\/p>\n<p>You can also use the options from the appropriate menu (Code Tools) using the Code Editor or console.<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6624\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-9.png\" alt=\"\" width=\"661\" height=\"273\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-9.png 661w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2017\/03\/r-programmung-2-9-300x124.png 300w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<h2>Two-way navigation<\/h2>\n<p>During the navigation through the code, it is often necessary to quickly return to the previous location. RStudio keeps a list of edits and allows you to jump from one to another in any direction by using the command Back (Back) and Forward (Forward) (available from the Edit menu, as well as in the upper left corner of the Code Editor). The Back and Forward commands allow you to repeat the following steps:<\/p>\n<ul>\n<li>Opening a document (or switch between tabs)<\/li>\n<li>The transition to the definition of function<\/li>\n<li>Go to a specific line of code<\/li>\n<li>Go to the function using the Function menu<\/li>\n<\/ul>\n<p>The Back and Forward commands can be accessed by using the keyboard shortcut Ctrl + F9 \/ Ctrl + F10 (Cmd + F9 \/ Cmd + F10 on Mac).<\/li>\n<\/ol>\n<h2>R Programming Assistance from Professionals<\/h2>\n<blockquote><p><em>You have just gotten acquainted with one of our R programming examples. Actually, this was only the second part of our sample. The first and the third parts you can also find on our website. All of them are absolutely free, so you don\u2019t need to worry that you will have to pay. We have completed this free sample with the aim to show our clients how tasks of this type should look. In other words, we wanted to present to you how theoretical rules are applied in practice. We hope our example really helped you to understand the topic better.<\/em><\/p>\n<p><em>Our example was completed by an expert that is knowledgeable in R programming. Our other samples are also completed by people that have achieved mastery in specific disciplines. We test our candidates extremely thoroughly so that we are confident that they are able to provide our clients with high-quality samples.<\/em><\/p>\n<p><em>If the R programming examples that are presented on our blog didn\u2019t help you, you can apply to us for additional <a href=\"https:\/\/assignmentshark.com\/r-homework-help.html\" target=\"_blank\" rel=\"noopener\">R homework help<\/a>. What kind of help do we mean? You have the ability to order a sample that will be completed just for you. You should fill the order form where you will need to specify the discipline, the deadline and the topic, and then provide us with materials that we\u2019ll need to use to complete your order. Afterward, you will get pricing offers from experts and you will need to choose the expert that you like most of all. During the process, you should keep in touch with your expert so that your sample will be written according to your needs.<\/em><\/p>\n<p><em>No matter how much time is left before your deadline, contact us if you need <a href=\"https:\/\/assignmentshark.com\/do-my-computer-science-homework.html\" target=\"_blank\" rel=\"noopener\">computer scince help<\/a>. We are available 24\/7!<\/em><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Code editing and executing General information The RStudio code editor includes a number of options for productive work \u2013 in particular, code highlighting, code completion, simultaneous editing of multiple files, and searching and replacing certain parts of the code.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,35],"tags":[],"class_list":["post-6590","post","type-post","status-publish","format-standard","hentry","category-it","category-samples"],"_links":{"self":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/6590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/comments?post=6590"}],"version-history":[{"count":17,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/6590\/revisions"}],"predecessor-version":[{"id":13167,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/6590\/revisions\/13167"}],"wp:attachment":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/media?parent=6590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/categories?post=6590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/tags?post=6590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}