{"id":391,"date":"2018-10-16T16:59:48","date_gmt":"2018-10-16T16:59:48","guid":{"rendered":"http:\/\/depts.washington.edu\/aromad\/?page_id=391"},"modified":"2020-01-03T04:14:23","modified_gmt":"2020-01-03T04:14:23","slug":"genes-rstudio-data-query-example-simple","status":"publish","type":"page","link":"http:\/\/depts.washington.edu\/aromad\/genes-rstudio-data-query-example-simple\/","title":{"rendered":"Gene&#8217;s R Examples (SIMPLE via Rstudio IDE)"},"content":{"rendered":"<p>The following examples are one of many data query options via RStudio:<\/p>\n<p>First, you will want to download the <span style=\"color: #ff0000;\"><strong>dplyr\u00a0<\/strong><span style=\"color: #000000;\">package.\u00a0<\/span><\/span><\/p>\n<p><span style=\"color: #3366ff;\">Then type:\u00a0<\/span><br \/>\n&gt;library(<span style=\"color: #ff0000;\"><strong>dplyr<\/strong><span style=\"color: #000000;\">)<\/span><\/span><\/p>\n<p><span style=\"color: #3366ff;\">Then give your object a name, in this case &#8220;applejack&#8221;:\u00a0<\/span><\/p>\n<p>&gt;applejack\u00a0\u00a0<strong>&lt;-<\/strong> Actual name of your data table.<\/p>\n<p><span style=\"color: #3366ff;\">If you want to see all the names of the variables\/column headings, you have the option to type the following:\u00a0<\/span><\/p>\n<p>&gt;<strong>names<\/strong> (applejack)<\/p>\n<p><span style=\"color: #3366ff;\">Now give your object another name to query the column heading\/variables you want to select:<\/span><\/p>\n<blockquote>\n<p>applejack<span style=\"color: #ff0000;\"><strong>1<\/strong><\/span>&lt;-<strong>select<\/strong>(applejack, variable1, variable2, variable3, variabl4, variable 5&#8230;&#8230;.)<\/p>\n<p>or<\/p>\n<p>applejack<span style=\"color: #ff0000;\"><strong>1<\/strong><\/span>&lt;-<strong>select<\/strong>(applejack, variable1:variable19)<\/p>\n<\/blockquote>\n<p>&gt;applejack<strong><span style=\"color: #ff0000;\">2<\/span><\/strong> &lt;- <strong>filter<\/strong> (applejack<span style=\"color: #ff0000;\"><strong>1<\/strong><\/span>, Variable2==&#8217;Y&#8217;,variable5\u00a0 &gt; 3.5 )<\/p>\n<p>&gt;applejack<strong><span style=\"color: #ff0000;\">2<\/span><\/strong><\/p>\n<p><span style=\"color: #3366ff;\">Now you will see your queried data in upper right hand corner of your RStudio.\u00a0<\/span><\/p>\n<p>_____________________________________________________________________________________<\/p>\n<p><span style=\"color: #3366ff;\">Another option is to utilize the\u00a0\u00a0<span style=\"color: #ff0000;\"><strong>dplyr\u00a0<\/strong><span style=\"color: #000000;\"> pipe function:\u00a0<\/span><\/span><\/span><\/p>\n<p>&gt;applejack %&gt;% <strong>select<\/strong>(variable1, variable2, variable3, variabl4, variable5&#8230;&#8230;.) %&gt;% <strong>filter <\/strong>(Variable2==&#8217;Y&#8217;,variable5\u00a0 &gt; 3.5)<\/p>\n<blockquote>\n<p>applejack<\/p>\n<p>or<\/p>\n<p>&gt;applejack %&gt;% <strong>select<\/strong>(variable1:variable5&#8230;&#8230;.) %&gt;% <strong>filter <\/strong>(Variable2==&#8217;Y&#8217;,variable5\u00a0 &gt; 3.5)<\/p>\n<blockquote>\n<p>applejack<\/p>\n<\/blockquote>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">If you want to arrange your selected\/generated data frame in certain order and want to see up to 20 rows information you are about to generate, you can use the following command:\u00a0<\/span><\/p>\n<p><span style=\"color: #3366ff;\"> \u00a0<\/span>&gt; applejack %&gt;% <strong>arrange<\/strong>(variable1)%&gt;%<strong>print<\/strong>(n=20)<\/p>\n<p>____________________________________________________________________________________<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following examples are one of many data query options via RStudio: First, you will want to download the dplyr\u00a0package.\u00a0 Then type:\u00a0 &gt;library(dplyr) Then give your object a name, in this case &#8220;applejack&#8221;:\u00a0 &gt;applejack\u00a0\u00a0&lt;- Actual name of your data table. If you want to see all the names of the variables\/column headings, you have the&#8230;<\/p>\n<div><a class=\"more\" href=\"http:\/\/depts.washington.edu\/aromad\/genes-rstudio-data-query-example-simple\/\">Read more<\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-391","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/pages\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":18,"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/pages\/391\/revisions"}],"predecessor-version":[{"id":544,"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/pages\/391\/revisions\/544"}],"wp:attachment":[{"href":"http:\/\/depts.washington.edu\/aromad\/wp-json\/wp\/v2\/media?parent=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}