{"id":2148,"date":"2024-07-13T21:26:57","date_gmt":"2024-07-13T21:26:57","guid":{"rendered":"https:\/\/ibp.ir\/?p=2148"},"modified":"2024-12-17T07:55:47","modified_gmt":"2024-12-17T08:55:47","slug":"1-%d9%85%d9%82%d8%af%d9%85%d9%87-%d9%88-%d8%b4%d8%b1%d9%88%d8%b9-%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d9%87-%d9%86%d9%88%db%8c%d8%b3%db%8c-%d8%a8%d8%a7-r","status":"publish","type":"post","link":"https:\/\/ibp.ir\/?p=2148","title":{"rendered":"1: \u0645\u0642\u062f\u0645\u0647 \u0648 \u0634\u0631\u0648\u0639 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u0628\u0627 R"},"content":{"rendered":"<div class=\"container-fluid main-container\">\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R (programming language) training course. By:Babak Babaabasi<\/strong><\/h2>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2149\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-13-192003.png\" alt=\"\" width=\"610\" height=\"334\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-13-192003.png 1153w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-13-192003-300x164.png 300w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-13-192003-1024x560.png 1024w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-13-192003-768x420.png 768w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>(1)R Tutorial:<\/strong><\/h2>\n<h3 dir=\"ltr\" style=\"text-align: left;\"><strong>Why Are There So Many Programming Languages?<\/strong><\/h3>\n<p dir=\"ltr\" style=\"text-align: left;\">There are so many programming languages out there, and more are developed every few years. We have Python, JavaScript, PHP, C++, Ruby, Java, C#, and way too many more to list here.<\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2153\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/2-3.jpg\" alt=\"\" width=\"1730\" height=\"1215\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/2-3.jpg 1730w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/2-3-300x211.jpg 300w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/2-3-1024x719.jpg 1024w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/2-3-768x539.jpg 768w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/2-3-1536x1079.jpg 1536w\" sizes=\"auto, (max-width: 1730px) 100vw, 1730px\" \/><\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Here are some developer jobs and the main programming languages they use:<\/p>\n<ul dir=\"ltr\" style=\"text-align: left;\">\n<li>Game developers use C++ or C# to make video games for PCs and consoles.<\/li>\n<li>Web developers use HTML, CSS, JavaScript, and PHP to make websites and web applications.<\/li>\n<li>Mobile app developers use Java and Kotlin to make Android applications or use Swift to make iOS applications.<\/li>\n<li>Software developers use C++, C#, and Java to make desktop applications, business applications, and system software.<\/li>\n<li>Data scientists use Python, R, and MatLab to analyze data for scientific research and educational purposes.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2154\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/3.jpg\" alt=\"\" width=\"574\" height=\"574\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/3.jpg 574w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/3-300x300.jpg 300w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/3-150x150.jpg 150w\" sizes=\"auto, (max-width: 574px) 100vw, 574px\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>top data science programming languages:<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2155\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/4.gif\" alt=\"\" width=\"1330\" height=\"908\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>download R<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2159\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-14-004014.png\" alt=\"\" width=\"1123\" height=\"700\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-14-004014.png 1123w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-14-004014-300x187.png 300w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-14-004014-1024x638.png 1024w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/Screenshot-2024-07-14-004014-768x479.png 768w\" sizes=\"auto, (max-width: 1123px) 100vw, 1123px\" \/><\/p>\n<h3 dir=\"ltr\" style=\"text-align: left;\">install r<\/h3>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2160\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/5-10.png\" alt=\"\" width=\"499\" height=\"392\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/5-10.png 499w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/5-10-300x236.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/p>\n<h3 dir=\"ltr\" style=\"text-align: left;\"><strong>run r<\/strong><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2161\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/6-10.png\" alt=\"\" width=\"696\" height=\"567\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/6-10.png 696w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/6-10-300x244.png 300w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>first code with r<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">print(&#8220;helooooo&#8221;)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;helooooo&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">#or you can type<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">&#8220;heloooo&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;heloooo&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>first calculation with r<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">5+5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 10<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>IDE<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2162\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/7-1.jpg\" alt=\"\" width=\"1099\" height=\"733\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/7-1.jpg 1099w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/7-1-300x200.jpg 300w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/7-1-1024x683.jpg 1024w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/7-1-768x512.jpg 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>r studio<\/strong><\/h2>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2163\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/8-1.jpg\" alt=\"\" width=\"1200\" height=\"630\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/8-1.jpg 1200w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/8-1-300x158.jpg 300w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/8-1-1024x538.jpg 1024w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/8-1-768x403.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<h3 dir=\"ltr\" style=\"text-align: left;\"><strong>why r stodu<\/strong><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2164\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/9-5.png\" alt=\"\" width=\"568\" height=\"600\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/9-5.png 568w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/9-5-284x300.png 284w\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" \/><\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Here are the major windows (or panes) of the RStudio environment:<\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2165\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/10-9.png\" alt=\"\" width=\"2394\" height=\"1812\" srcset=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/10-9.png 2394w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/10-9-300x227.png 300w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/10-9-1024x775.png 1024w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/10-9-768x581.png 768w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/10-9-1536x1163.png 1536w, https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/10-9-2048x1550.png 2048w\" sizes=\"auto, (max-width: 2394px) 100vw, 2394px\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>what is the difference between r script and r notebook<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">The primary difference is that <strong>when executing chunks in an R Markdown document, all the code is sent to the console at once, but in a notebook, only one line at a time is sent<\/strong>. This allows execution to stop if a line raises an error.<\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2166\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/11.gif\" alt=\"\" width=\"701\" height=\"523\" \/><\/p>\n<h3 dir=\"ltr\" style=\"text-align: left;\"><strong>r script example<\/strong><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2167\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/12.gif\" alt=\"\" width=\"979\" height=\"607\" \/><\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong>r notebook example<\/strong><\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2168\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/13.gif\" alt=\"\" width=\"1305\" height=\"961\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Syntax<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">To output text in R, use single or double quotes: To output numbers, just type the number (without quotes)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">&#8220;heloooo&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;heloooo&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># for number without quotes<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">5+5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 10<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Print Output<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Unlike many other programming languages, you can output code in R without using a print function:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print(&#8220;helooooo&#8221;)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;helooooo&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">And there are times you must use the print() function to output code, for example when working with <a href=\"https:\/\/www.w3schools.com\/r\/r_for_loop.asp\">for<\/a> loops (which you will learn more about in a later chapter):<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">for (x in 1:10) {<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">\u00a0 print(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">}<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 1<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 2<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 3<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 4<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 6<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 7<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 8<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 9<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 10<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Comments<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Comments starts with a #. When executing code, R will ignore anything that starts with #.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Unlike other programming languages, such as <a href=\"https:\/\/www.w3schools.com\/java\/java_comments.asp\">Java<\/a>, there are no syntax in R for multiline comments. However, we can just insert a # for each line to create multiline comments:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># This is a comment<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># written in<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># more than just one line<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">&#8220;Hello World!&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;Hello World!&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Variables<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">To assign a value to a variable, use the &lt;- or <strong>=<\/strong> signs\ud83e\udd74. To output (or print) the variable value, just type the variable name:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">name = &#8220;babak&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">age &lt;- 36<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">surname=&#8221;babaabasi&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># output Variables<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">name<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;babak&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">age<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 36<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">surname<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;babaabasi&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>Concatenate Elements<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">You can also concatenate, or join, two or more elements, by using the paste() function.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">To combine both text and a variable, R uses comma (,):<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print(c(name,surname))<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;babak&#8221;\u00a0\u00a0\u00a0\u00a0 &#8220;babaabasi&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print(c(name,&#8221; &#8220;,surname,&#8221; is &#8220;,age,&#8221; years old.&#8221;))<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;babak&#8221;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8221; &#8221;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;babaabasi&#8221;\u00a0\u00a0 &#8221; is &#8221;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;36&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [6] &#8221; years old.&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print(paste(name,&#8221;_&#8221;,surname, &#8220;is&#8221; ,age,&#8221; years old.&#8221;))<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;babak _ babaabasi is 36\u00a0 years old.&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"><strong>======<\/strong><\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">ages=c(26,23,35,56)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">mean(ages)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 35<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">m=mean(ages)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">text &lt;- &#8220;awesome&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">paste(&#8220;R is&#8221;, text)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;R is awesome&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">text1 &lt;- &#8220;R is&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">text2 &lt;- &#8220;awesome&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">paste(text1, text2)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;R is awesome&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">For numbers, the + character works as a mathematical operator:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">num1 &lt;- 5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">num2 &lt;- 10<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">num1 + num2<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 15<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>Variable Names<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Rules for R variables are:<\/p>\n<ul dir=\"ltr\" style=\"text-align: left;\">\n<li>A variable name must start with a letter and can be a combination of letters, digits, period(.)<br \/>\nand underscore(_). If it starts with period(.), it cannot be followed by a digit.<\/li>\n<li>A variable name cannot start with a number or underscore (_)<\/li>\n<li>Variable names are case-sensitive (age, Age and AGE are three different variables)<\/li>\n<li>Reserved words cannot be used as variables (TRUE, FALSE, NULL, if\u2026)<\/li>\n<\/ul>\n<p dir=\"ltr\" style=\"text-align: left;\"># Legal variable names:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">myvar &lt;- &#8220;John&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">my_var &lt;- &#8220;John&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">myVar &lt;- &#8220;John&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">MYVAR &lt;- &#8220;John&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">myvar2 &lt;- &#8220;John&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">.myvar &lt;- &#8220;John&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Data Types<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">In programming, data type is an important concept.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Variables can store data of different types, and different types can do different things.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">In R, variables do not need to be declared with any particular type, and can even change type after they have been set:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">my_var &lt;- 30 # my_var is type of numeric<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">my_var &lt;- &#8220;Sally&#8221; # my_var is now of type character (aka string)<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>Basic Data Types<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Basic data types in R can be divided into the following types:<\/p>\n<ul dir=\"ltr\" style=\"text-align: left;\">\n<li>numeric &#8211; (10.5, 55, 787)<\/li>\n<li>integer &#8211; (1L, 55L, 100L, where the letter \u201cL\u201d declares this as an integer)<\/li>\n<\/ul>\n<p dir=\"ltr\" style=\"text-align: left;\">a number which is not a fraction; a whole number.\u201dinteger values\u201d<\/p>\n<ul dir=\"ltr\" style=\"text-align: left;\">\n<li>complex &#8211; (9 + 3i, where \u201ci\u201d is the imaginary part)<\/li>\n<li>character (a.k.a. string) &#8211; (\u201ck\u201d, \u201cR is exciting\u201d, \u201cFALSE\u201d, \u201c11.5\u201d)<\/li>\n<li>logical (a.k.a. boolean) &#8211; (TRUE or FALSE)<\/li>\n<\/ul>\n<p dir=\"ltr\" style=\"text-align: left;\">We can use the class() function to check the data type of a variable:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># numeric<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x = 10.5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;numeric&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># integer<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x2 &lt;- 1000L<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;numeric&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># complex<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- 9i + 3<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;complex&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># character\/string<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- &#8220;R is exciting&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;character&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># logical\/boolean<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- TRUE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;logical&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Numbers<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- 10.5\u00a0\u00a0 # numeric<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y &lt;- 10L\u00a0\u00a0\u00a0 # integer<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">z &lt;- 1i\u00a0\u00a0\u00a0\u00a0 # complex<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- 10.5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y &lt;- 55<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Print values of x and y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 10.5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 55<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Print the class name of x and y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;numeric&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(y)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;numeric&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- 1000L<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y &lt;- 55L<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Print values of x and y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 1000<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 55<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Print the class name of x and y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;integer&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(y)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;integer&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- 3+5i<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y &lt;- 5i<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Print values of x and y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 3+5i<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 0+5i<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Print the class name of x and y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;complex&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(y)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;complex&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>Type Conversion<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">You can convert from one type to another with the following functions:<\/p>\n<ul dir=\"ltr\" style=\"text-align: left;\">\n<li>as.numeric()<\/li>\n<li>as.integer()<\/li>\n<li>as.complex()<\/li>\n<\/ul>\n<p dir=\"ltr\" style=\"text-align: left;\">x=10.8<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;numeric&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">b=as.integer(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(b)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;integer&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">b<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 10<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x &lt;- 1L # integer<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y &lt;- 2 # numeric<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># convert from integer to numeric:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">a &lt;- as.numeric(x)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># convert from numeric to integer:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">b &lt;- as.integer(y)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># print values of x and y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">x<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 1<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">y<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 2<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># print the class name of a and b<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(a)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;numeric&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(b)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;integer&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">g=10.5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">g<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 10.5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(g)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;numeric&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">h=as.integer(g)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">h<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 10<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class(h)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;integer&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Math<\/strong><\/h2>\n<h3 dir=\"ltr\" style=\"text-align: left;\"><strong>Built-in Math Functions<\/strong><\/h3>\n<p dir=\"ltr\" style=\"text-align: left;\">R also has many built-in math functions that allows you to perform mathematical tasks on numbers.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">For example, the min() and max() functions can be used to find the lowest or highest number in a set:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">b=c(4,55,6,87,33,45)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">min(b)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 4<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">max(b)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 87<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">mean(b)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 38.33333<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">h=log(b)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">b<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1]\u00a0 4 55\u00a0 6 87 33 45<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">h<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 1.386294 4.007333 1.791759 4.465908 3.496508 3.806662<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">f=c(&#8220;a&#8221;,9,3,4,&#8221;babak&#8221;,&#8221;hasan&#8221;,36)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">min(f)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;3&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">v=mean(f)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## Warning in mean.default(f): argument is not numeric or logical: returning NA<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">max(f)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;hasan&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">g=as.numeric(f)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## Warning: NAs introduced by coercion<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">g<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] NA\u00a0 9\u00a0 3\u00a0 4 NA NA 36<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">min(g,na.rm = T)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 3<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">max(g)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] NA<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">mean(g,na.rm = T)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 13<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">log(g)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NA 2.197225 1.098612 1.386294\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NA\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NA 3.583519<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">max(5, 10, 15)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 15<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">min(5, 10, 15)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 5<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>abs()<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">The abs() function returns the absolute (positive) value of a number:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">abs(-4.7)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 4.7<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">abs(c(3,-4,-45))<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1]\u00a0 3\u00a0 4 45<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">k=c(-4,-5.5)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">f=abs(k)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">f<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 4.0 5.5<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>ceiling() and floor()<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">The ceiling() function rounds a number upwards to its nearest integer, and the floor() function rounds a number downwards to its nearest integer, and returns the result:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">ceiling(1.5)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 2<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">floor(1.5)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 1<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Strings<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">A character, or strings, are used for storing text. A string is surrounded by either single quotation marks, or double quotation marks:&#8221;hello&#8221; is the same as &#8216;hello&#8217;:<\/p>\n<h3 dir=\"ltr\" style=\"text-align: left;\"><strong>Assign a String to a Variable<\/strong><\/h3>\n<p dir=\"ltr\" style=\"text-align: left;\">str &lt;- &#8220;Hello&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">str # print the value of str<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;Hello&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">However, note that R will add a \u201c<strong>\\n<\/strong>\u201d at the end of each line break. This is called an escape character, and the <strong>n<\/strong> character indicates a <strong>new line<\/strong>.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">If you want the line breaks to be inserted at the same position as in the code, use the cat() function:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">str &lt;- &#8220;Lorem ipsum dolor sit amet,<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">consectetur adipiscing elit,<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">sed do eiusmod tempor incididunt<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">ut labore et dolore magna aliqua.&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">str # print the value of str<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;Lorem ipsum dolor sit amet,\\nconsectetur adipiscing elit,\\nsed do eiusmod tempor incididunt\\nut labore et dolore magna aliqua.&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">str &lt;- &#8220;Lorem ipsum dolor sit amet,<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">consectetur adipiscing elit,<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">sed do eiusmod tempor incididunt<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">ut labore et dolore magna aliqua.&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">cat(str)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## Lorem ipsum dolor sit amet,<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## consectetur adipiscing elit,<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## sed do eiusmod tempor incididunt<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## ut labore et dolore magna aliqua.<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>String Length<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">There are many usesful string functions in R.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">For example, to find the number of characters in a string, use the nchar() function<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">stf = &#8220;Hello World!&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">nchar(stf)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 12<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">length(stf)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 1<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">stv=c(&#8220;babak&#8221;,2,3,&#8221;hasan&#8221;)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">nchar(stv)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 5 1 1 5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">length(stv)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 4<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>Check a String<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Use the grepl() function to check if a character or a sequence of characters are present in a string:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">zahra=c(&#8220;zahra&#8221;,&#8221;18&#8243;,&#8221;safaee&#8221;,&#8221;isfehan&#8221;,&#8221;4418&#8243;)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">grepl(&#8220;hr&#8221;, zahra)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1]\u00a0 TRUE FALSE FALSE FALSE FALSE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">length(zahra)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">nchar(zahra)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 5 2 6 7 4<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">zahra2 &lt;- &#8220;Hello World!&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">grepl(&#8220;H&#8221;, zahra2)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] TRUE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">grepl(&#8220;Hello&#8221;, str)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] FALSE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">grepl(&#8220;X&#8221;, str)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] FALSE<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>Combine Two Strings<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Use the paste() function to merge\/concatenate two strings:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">zahra1 &lt;- &#8220;Hello&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">zahra2 &lt;- &#8220;World&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">paste(zahra1, zahra2)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;Hello World&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">str11=c(&#8220;babak&#8221;,&#8221;abasi&#8221;,&#8221;aaa&#8221;)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">str12=c(&#8220;hi&#8221;,&#8221;my&#8221;,36)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">a=paste(str11, str12)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">a<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] &#8220;babak hi&#8221; &#8220;abasi my&#8221; &#8220;aaa 36&#8221;<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Booleans \/ Logical Values<\/strong><\/h2>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>Booleans (Logical Values)<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">In programming, you often need to know if an expression is <strong>true<\/strong> or <strong>false<\/strong>.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">You can evaluate any expression in R, and get one of two answers, TRUE or FALSE.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">When you compare two values, the expression is evaluated and R returns the logical answer:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">10 &gt; 9<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] TRUE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">10 &lt; 9<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] FALSE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">10 &gt;= 9\u00a0\u00a0\u00a0 # TRUE because 10 is greater than 9<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] TRUE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">10 == 9\u00a0\u00a0 # FALSE because 10 is not equal to 9<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] FALSE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">10 &lt;= 9\u00a0\u00a0\u00a0 # FALSE because 10 is greater than 9<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] FALSE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">&#8220;babak&#8221;==&#8221;babak&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] TRUE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">&#8220;farza&#8221;==&#8221;zahra&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] FALSE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">You can also compare two variables:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">a = 10<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">b = 9<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">a &gt; b<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] TRUE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">s=c(2,33,34,55)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">w=c(3,44,67)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">s&lt;w<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## Warning in s &lt; w: longer object length is not a multiple of shorter object<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## length<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1]\u00a0 TRUE\u00a0 TRUE\u00a0 TRUE FALSE<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">s&gt;w<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## Warning in s &gt; w: longer object length is not a multiple of shorter object<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## length<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] FALSE FALSE FALSE\u00a0 TRUE<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Operators<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Operators are used to perform operations on variables and values.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">In the example below, we use the + operator to add together two values:<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">\u00a010 + 5<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 15<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">R divides the operators in the following groups:<\/p>\n<ul dir=\"ltr\" style=\"text-align: left;\">\n<li>Arithmetic operators<\/li>\n<li>Assignment operators<\/li>\n<li>Comparison operators<\/li>\n<li>Logical operators<\/li>\n<li>Miscellaneous operators<\/li>\n<\/ul>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Arithmetic Operators<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Arithmetic operators are used with numeric values to perform common mathematical operations:<\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2169\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/14.gif\" alt=\"\" width=\"956\" height=\"464\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Assignment Operators<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Assignment operators are used to assign values to variables<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">my_var &lt;- 3<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">my_var1 = 3<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">my_var # print my_var<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 3<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">my_var1<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">## [1] 3<\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Comparison Operators<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Comparison operators are used to compare two values:<\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2172\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/16.gif\" alt=\"\" width=\"923\" height=\"412\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Logical Operators<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Logical operators are used to combine conditional statements:<\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2171\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/15.gif\" alt=\"\" width=\"1313\" height=\"338\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>R Miscellaneous Operators<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">Miscellaneous operators are used to manipulate data:<\/p>\n<p dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2173\" src=\"https:\/\/ibp.ir\/wp-content\/uploads\/2024\/07\/17.gif\" alt=\"\" width=\"1310\" height=\"231\" \/><\/p>\n<h2 dir=\"ltr\" style=\"text-align: left;\"><strong>END(1-1)<\/strong><\/h2>\n<p dir=\"ltr\" style=\"text-align: left;\">\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>R (programming language) training course. By:Babak Babaabasi (1)R Tutorial: Why Are There So Many Programming Languages? There are so many programming languages out there, and more are developed every few years. We have Python, JavaScript, PHP, C++, Ruby, Java, C#, and way too many more to list here. Here are some developer jobs and the main programming languages they use: Game developers use C++ or C# to make video games for PCs and consoles. Web developers use[&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":2153,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2148","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1"],"views":175,"_links":{"self":[{"href":"https:\/\/ibp.ir\/index.php?rest_route=\/wp\/v2\/posts\/2148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibp.ir\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibp.ir\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibp.ir\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibp.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2148"}],"version-history":[{"count":8,"href":"https:\/\/ibp.ir\/index.php?rest_route=\/wp\/v2\/posts\/2148\/revisions"}],"predecessor-version":[{"id":2195,"href":"https:\/\/ibp.ir\/index.php?rest_route=\/wp\/v2\/posts\/2148\/revisions\/2195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibp.ir\/index.php?rest_route=\/wp\/v2\/media\/2153"}],"wp:attachment":[{"href":"https:\/\/ibp.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibp.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibp.ir\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}