{"id":453,"date":"2018-07-13T12:41:01","date_gmt":"2018-07-13T12:41:01","guid":{"rendered":"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=453"},"modified":"2019-05-16T09:33:32","modified_gmt":"2019-05-16T09:33:32","slug":"r-programming-1","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/chapter\/r-programming-1\/","title":{"rendered":"R Programming &#8211; 1"},"content":{"raw":"<div><span style=\"float: right;\"><a href=\"https:\/\/youtu.be\/v7S071_mKUo\" target=\"_blank\" rel=\"noopener\"><img src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a>\r\n<\/span><\/div>\r\n&nbsp;\r\n\r\n<strong>Overview of R<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">R is an open source program licensed under GNU GPL, it is a Software Environment for Statistical Computing . R supports a variety of statistical functions, programming and graphics related utilities. R is widely used by statisticians, data miners and researchers as a statistical tool. Recently, R has gained wide popularity due to the capabilities of machine learning utilities which can be done very easily by importing libraries. R is available for most of the operating systems. R has a command line interface, there are several GUI front-ends that support R.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify;\">R is an effective programming language. R provides a variety of programming features like variables, conditions, loops, user defined recursive functions, datasets facilities. R also has facilities for data handling, calculations, retrieval and strage facilities. R provides a wide range of operators for calculations on arrays, data structures like lists, vectors and matrices. It provides integrated collection of tools for data analysis. R provides graphical facilities for to create charts, plots in desired formats.<\/p>\r\n&nbsp;\r\n\r\n<strong>Download and Installation<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">R can be downloaded from its website <a href=\"https:\/\/www.r-project.org\/\">https:\/\/www.r-project.org, <\/a>R is available for most of the operating systems. It is available for Windows in binary form while it can be installed on Red Hat based distributions using the following command:<\/p>\r\n&nbsp;\r\n\r\n$sudo yum install R -y\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">Alternatively, R can be downloaded as a source code and can be compiled into a package on Unix like systems<\/p>\r\n&nbsp;\r\n\r\n<strong>Interface &amp; Other tools<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">The interface of R can be either in command prompt or there are GUI tools that are made available by third party for programming in R. The following screen shows a command line interface that is available after downloading R from the above-mentioned website:<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-454 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000.jpg\" alt=\"\" width=\"1366\" height=\"707\" \/><\/p>\r\n<p style=\"text-align: center;\"><strong>Figure 1: Default R Console<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify;\">The default software uses command line interface. We can run commands using the command line interface or execute R scripts using the same interface. Following are few examples of using the command line interface to execute commands and R scripts.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-455 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/k112132.png\" alt=\"\" width=\"644\" height=\"154\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">As shown in above screen, R can be started by using 'R' command on $ prompt. A special '&gt;' prompt is seen for R. We can type commands on this prompt one by one and get commands executed. The output will also be generated on the same prompt. R, also supports execution of scripts. The scripts can be typed in text format in some file, say \"first.R\" and it can be executed by issuing the command Rscript on the command prompt. The execution of R scripts is shown below:<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-456 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/k25413203.png\" alt=\"\" width=\"649\" height=\"239\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>Commands related to R Environment<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">R provides functions to interact with the environment of system. R has its own default working directory that can be listed using getwd() function. We can also set the working directory to some other desired directory of secondary storage. Through the R command prompt, list of files is also possible using dir() function. The following table shows few widely used functions of R:<\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-457 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-1.png\" alt=\"\" width=\"626\" height=\"221\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>Packages in R<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">The real power of R is hidden in its wide variety of packages. R packages are a collection of R functions, complied code and sample data, the packages are used for specific functionality. They are stored under a directory called <strong>\"library\"<\/strong> in the R environment. R comes by default with a set of packages during installation. Depending on the requirement, more packages can be added later, when they are needed for some specific purpose. When we start the R console, only the default packages are available in standard installation.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-458 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled1.png\" alt=\"\" width=\"545\" height=\"188\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">R provides a variety of packages for executing specialized tasks. There are packages for numerical computing, machine learning, financial calculations, etc. The above table lists functions that can be used to display\/search packages or install additional packages that are not provide in standard installation of R. Functions like help() or help.start() can be used to browse various topics available in the R manual. The above listed commands\/functions can be typed on the command prompt screen as shown in below figure:<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-459 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/u1.jpg\" alt=\"\" width=\"691\" height=\"482\" \/><\/p>\r\n<p style=\"text-align: center;\">Figure 2: Command prompt to execute various functions of R<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>Using Command Prompt for R programming<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">Let us go through some example, how command prompt can be used to execute different commands of R. As seen in the below code, the command prompt '&gt;' is used to execute mathematical calculations. Assignment of value to variables can be done using '-&gt;' symbol or also by using the assign() function as shown below:<\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-460 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled2123214.png\" alt=\"\" width=\"632\" height=\"191\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>Programming Support in R<\/strong>\r\n\r\n&nbsp;\r\n\r\nIn R programming, there is a rich set of data type support as in 'C' language. R supports a wide variety of data types that are listed in following table:\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-461 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/seesfres.png\" alt=\"\" width=\"678\" height=\"410\" \/><\/p>\r\n<p style=\"text-align: justify;\">Since R is a scientific tool, it supports complex data types and also supports raw data type where the data \u00edtems can be a mix of text and numeric values.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify;\">The following table lists varios operators that are supported by R. As we have already seen, R supports arithmetic operations through command prompt or through scripts. The following operators can be used over variables\/numbers to perform calculations:<\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-462 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/X90-1.png\" alt=\"\" width=\"432\" height=\"223\" \/><\/p>\r\nR also supports a rich set of logical operators to carry out comparison of values. The list of logical operators are shown in following table:\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-463 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/fdgdfgfd.png\" alt=\"\" width=\"467\" height=\"173\" \/><\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-464 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/0000.png\" alt=\"\" width=\"487\" height=\"84\" \/><\/p>\r\n<strong>Data Structures in R<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">Data structures are generally used to store multiple \u00edtems using a common variable name. In R, there are two categories of data structures. Data structures that store homogeneous values and those that store heterogeneous values. Data structures supported by R are:<\/p>\r\n\r\n<ul>\r\n \t<li>atomic vector<\/li>\r\n \t<li>list<\/li>\r\n \t<li>matrix<\/li>\r\n \t<li>data frame<\/li>\r\n \t<li>factors<\/li>\r\n \t<li>tables<\/li>\r\n<\/ul>\r\n<p style=\"text-align: justify;\">Atomic vector is a data type that store values of same type. The vector can be created using 'c()' function as shown in the below code:<\/p>\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-465 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/esretertdr.png\" alt=\"\" width=\"582\" height=\"367\" \/><\/p>\r\n&nbsp;\r\n\r\nOutput of the above code is shown in following figure:\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-466 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/ererererteeeeeeeeeeeeeeeeeeeeeeee.jpg\" alt=\"\" width=\"397\" height=\"119\" \/><\/p>\r\nThe matrix function accepts arguments like no. of rows, no. of columns, arrangement of elements and data items. These arguments are described in following table:\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-467 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-2.png\" alt=\"\" width=\"461\" height=\"179\" \/><\/p>\r\n<p style=\"text-align: justify;\">A data frame is a two-dimensional array-like structure in which each column contains values of one variable and each row contains for columns. Data frames are used when we want to process data that is available in CSV or Spreadsheet format. Data frames can parse large number of records very quickly. Following are the characteristics required to create a data frame<\/p>\r\n\r\n<ul>\r\n \t<li>The column names must be there<\/li>\r\n \t<li>The row names should be unique<\/li>\r\n \t<li>Each column should contain same number of data items<\/li>\r\n<\/ul>\r\nThe following code creates a data frame of 6 letters and two columns labelled 'x' and 'y'.\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-468 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/23242.png\" alt=\"\" width=\"577\" height=\"339\" \/><\/p>\r\n<img class=\"alignnone size-full wp-image-469 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/dddd.jpg\" alt=\"\" width=\"440\" height=\"84\" \/>\r\n\r\n<strong>Datasets<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">For those who do not want to create datasets, R provides inbuilt datasets that can be accessed by command prompt. In most of the standard installations, few datasets are provided by R. Let us see an example of 'mtcars' dataset that is provided by default in R installations. By typing 'mtcars' on command prompt, it lists the dataset values as shown in following figure:<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center;\"><img class=\"size-full wp-image-470 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa.jpg\" alt=\"\" width=\"866\" height=\"460\" \/><\/p>\r\nWe can create a table of data items form the above mentioned dataset. We can also select or summarize columns as shown in following code:\r\n\r\n<img class=\"alignnone size-full wp-image-471 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/sadsddsfsdfs.png\" alt=\"\" width=\"596\" height=\"233\" \/>\r\n\r\n<strong>Functions in R<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify;\">R provides a wide variety of functions. Functions can be used for mathematical, statistical, financial calculations. The list of functions provided by R can be browsed using the 'help()' command on prompt. Let us see how functions can be used in R. The following code shows the use of statistical functions mean and median over an array of numbers.<\/p>\r\n<img class=\"alignnone size-full wp-image-473 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/fgfgg.png\" alt=\"\" width=\"584\" height=\"110\" \/>\r\n\r\n&nbsp;\r\n\r\nLet us summarize the key concepts covered in this module\r\n<ul>\r\n \t<li>What is the need of R<\/li>\r\n \t<li>How to install and use R<\/li>\r\n \t<li>Overview of variables and operators<\/li>\r\n \t<li>How to use data structures<\/li>\r\n \t<li>Overview of functions and packages<\/li>\r\n<\/ul>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>you can view video on R Programming - 1<\/strong><\/td>\r\n<td><a href=\"https:\/\/youtu.be\/v7S071_mKUo\" target=\"_blank\" rel=\"noopener\"><img class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n\r\n<strong>References for R Programming:<\/strong>\r\n<ol>\r\n \t<li style=\"text-align: justify;\">Felix Alvaro. <em>R\u202f: Easy R programming for beginners, your step-by-step guide to<\/em> <em>learning R programming<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">John Braun and Duncan James Murdoch. <em>A first course in statistical programming<\/em> <em>with R<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">John M. Chambers. 2008. <em>Software for data analysis\u202f: programming with R<\/em>, Springer.Michael J. Crawley. <em>The R book<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Tilman M. Davies. <em>The book of R\u202f: a first course in programming and statistics<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Mark. Gardener. 2012. <em>Beginning R\u202f: the Statistical Programming Language.<\/em>, John Wiley &amp; Sons.<\/li>\r\n \t<li style=\"text-align: justify;\">Colin (Colin Stevenson) Gillespie and Robin Lovelace. <em>Efficient R programming\u202f: a<\/em> <em>practical guide to smarter programming<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Garrett Grolemund. <em>Hands-on programming with R<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Thomas Mailund. <em>Advanced Object-Oriented Programming in R\u202f: Statistical<\/em><em style=\"text-align: initial; font-size: 1em;\">Programing for Data Science, Analysis and Finance<\/em><span style=\"text-align: initial; font-size: 1em;\">,<\/span><\/li>\r\n \t<li style=\"text-align: justify;\">Norman S. Matloff. 2011. <em>The art of R programming\u202f: tour of statistical software<\/em> <em>design<\/em>, No Starch Press.<\/li>\r\n \t<li style=\"text-align: justify;\">Shuichi Ohsaki, Jori Ruppert-Felsot, and Daisuke Yoshikawa. <em>R programming and its<\/em> <em>applications in financial mathematics<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Kun Ren. <em>Modern R programming cookbook\u202f: recipes to simplify your statistical<\/em> <em>applications<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Kun Ren. <em>Learning R programming\u202f: become an efficient data scientist with R<\/em>,<\/li>\r\n \t<li style=\"text-align: justify;\">Omar. Trejo and Peter. C. Figliozzi. 2017. <em>R Programming By Example Practical,<\/em> <em>hands-on projects to help you get started with R.<\/em>, Packt Publishing.<\/li>\r\n \t<li style=\"text-align: justify;\">Alain F. Zuur, Elena N. Ieno, and Erik. Meesters. 2009. <em>A beginner\u2019s guide to R<\/em>, Springer.<\/li>\r\n \t<li style=\"text-align: justify;\">Anon. R: The R Project for Statistical Computing. Retrieved March 19, 2017 from https:\/\/www.r-project.org\/<\/li>\r\n<\/ol>","rendered":"<div><span style=\"float: right;\"><a href=\"https:\/\/youtu.be\/v7S071_mKUo\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a><br \/>\n<\/span><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Overview of R<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">R is an open source program licensed under GNU GPL, it is a Software Environment for Statistical Computing . R supports a variety of statistical functions, programming and graphics related utilities. R is widely used by statisticians, data miners and researchers as a statistical tool. Recently, R has gained wide popularity due to the capabilities of machine learning utilities which can be done very easily by importing libraries. R is available for most of the operating systems. R has a command line interface, there are several GUI front-ends that support R.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">R is an effective programming language. R provides a variety of programming features like variables, conditions, loops, user defined recursive functions, datasets facilities. R also has facilities for data handling, calculations, retrieval and strage facilities. R provides a wide range of operators for calculations on arrays, data structures like lists, vectors and matrices. It provides integrated collection of tools for data analysis. R provides graphical facilities for to create charts, plots in desired formats.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Download and Installation<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">R can be downloaded from its website <a href=\"https:\/\/www.r-project.org\/\">https:\/\/www.r-project.org, <\/a>R is available for most of the operating systems. It is available for Windows in binary form while it can be installed on Red Hat based distributions using the following command:<\/p>\n<p>&nbsp;<\/p>\n<p>$sudo yum install R -y<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Alternatively, R can be downloaded as a source code and can be compiled into a package on Unix like systems<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Interface &amp; Other tools<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">The interface of R can be either in command prompt or there are GUI tools that are made available by third party for programming in R. The following screen shows a command line interface that is available after downloading R from the above-mentioned website:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-454 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000.jpg\" alt=\"\" width=\"1366\" height=\"707\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000.jpg 1366w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000-300x155.jpg 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000-768x397.jpg 768w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000-1024x530.jpg 1024w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000-65x34.jpg 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000-225x116.jpg 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k00000-350x181.jpg 350w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p style=\"text-align: center;\"><strong>Figure 1: Default R Console<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">The default software uses command line interface. We can run commands using the command line interface or execute R scripts using the same interface. Following are few examples of using the command line interface to execute commands and R scripts.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-455 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/k112132.png\" alt=\"\" width=\"644\" height=\"154\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k112132.png 644w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k112132-300x72.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k112132-65x16.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k112132-225x54.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k112132-350x84.png 350w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">As shown in above screen, R can be started by using &#8216;R&#8217; command on $ prompt. A special &#8216;&gt;&#8217; prompt is seen for R. We can type commands on this prompt one by one and get commands executed. The output will also be generated on the same prompt. R, also supports execution of scripts. The scripts can be typed in text format in some file, say &#8220;first.R&#8221; and it can be executed by issuing the command Rscript on the command prompt. The execution of R scripts is shown below:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-456 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/k25413203.png\" alt=\"\" width=\"649\" height=\"239\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k25413203.png 649w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k25413203-300x110.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k25413203-65x24.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k25413203-225x83.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/k25413203-350x129.png 350w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Commands related to R Environment<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">R provides functions to interact with the environment of system. R has its own default working directory that can be listed using getwd() function. We can also set the working directory to some other desired directory of secondary storage. Through the R command prompt, list of files is also possible using dir() function. The following table shows few widely used functions of R:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-457 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-1.png\" alt=\"\" width=\"626\" height=\"221\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-1.png 626w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-1-300x106.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-1-65x23.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-1-225x79.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-1-350x124.png 350w\" sizes=\"auto, (max-width: 626px) 100vw, 626px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Packages in R<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">The real power of R is hidden in its wide variety of packages. R packages are a collection of R functions, complied code and sample data, the packages are used for specific functionality. They are stored under a directory called <strong>&#8220;library&#8221;<\/strong> in the R environment. R comes by default with a set of packages during installation. Depending on the requirement, more packages can be added later, when they are needed for some specific purpose. When we start the R console, only the default packages are available in standard installation.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-458 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled1.png\" alt=\"\" width=\"545\" height=\"188\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled1.png 545w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled1-300x103.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled1-65x22.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled1-225x78.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled1-350x121.png 350w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">R provides a variety of packages for executing specialized tasks. There are packages for numerical computing, machine learning, financial calculations, etc. The above table lists functions that can be used to display\/search packages or install additional packages that are not provide in standard installation of R. Functions like help() or help.start() can be used to browse various topics available in the R manual. The above listed commands\/functions can be typed on the command prompt screen as shown in below figure:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-459 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/u1.jpg\" alt=\"\" width=\"691\" height=\"482\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/u1.jpg 691w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/u1-300x209.jpg 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/u1-65x45.jpg 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/u1-225x157.jpg 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/u1-350x244.jpg 350w\" sizes=\"auto, (max-width: 691px) 100vw, 691px\" \/><\/p>\n<p style=\"text-align: center;\">Figure 2: Command prompt to execute various functions of R<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Using Command Prompt for R programming<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Let us go through some example, how command prompt can be used to execute different commands of R. As seen in the below code, the command prompt &#8216;&gt;&#8217; is used to execute mathematical calculations. Assignment of value to variables can be done using &#8216;-&gt;&#8217; symbol or also by using the assign() function as shown below:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-460 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled2123214.png\" alt=\"\" width=\"632\" height=\"191\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled2123214.png 632w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled2123214-300x91.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled2123214-65x20.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled2123214-225x68.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled2123214-350x106.png 350w\" sizes=\"auto, (max-width: 632px) 100vw, 632px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Programming Support in R<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>In R programming, there is a rich set of data type support as in &#8216;C&#8217; language. R supports a wide variety of data types that are listed in following table:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-461 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/seesfres.png\" alt=\"\" width=\"678\" height=\"410\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/seesfres.png 678w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/seesfres-300x181.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/seesfres-65x39.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/seesfres-225x136.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/seesfres-350x212.png 350w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/p>\n<p style=\"text-align: justify;\">Since R is a scientific tool, it supports complex data types and also supports raw data type where the data \u00edtems can be a mix of text and numeric values.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">The following table lists varios operators that are supported by R. As we have already seen, R supports arithmetic operations through command prompt or through scripts. The following operators can be used over variables\/numbers to perform calculations:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-462 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/X90-1.png\" alt=\"\" width=\"432\" height=\"223\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/X90-1.png 432w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/X90-1-300x155.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/X90-1-65x34.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/X90-1-225x116.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/X90-1-350x181.png 350w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/p>\n<p>R also supports a rich set of logical operators to carry out comparison of values. The list of logical operators are shown in following table:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-463 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/fdgdfgfd.png\" alt=\"\" width=\"467\" height=\"173\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fdgdfgfd.png 467w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fdgdfgfd-300x111.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fdgdfgfd-65x24.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fdgdfgfd-225x83.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fdgdfgfd-350x130.png 350w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-464 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/0000.png\" alt=\"\" width=\"487\" height=\"84\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/0000.png 487w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/0000-300x52.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/0000-65x11.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/0000-225x39.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/0000-350x60.png 350w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/p>\n<p><strong>Data Structures in R<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">Data structures are generally used to store multiple \u00edtems using a common variable name. In R, there are two categories of data structures. Data structures that store homogeneous values and those that store heterogeneous values. Data structures supported by R are:<\/p>\n<ul>\n<li>atomic vector<\/li>\n<li>list<\/li>\n<li>matrix<\/li>\n<li>data frame<\/li>\n<li>factors<\/li>\n<li>tables<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Atomic vector is a data type that store values of same type. The vector can be created using &#8216;c()&#8217; function as shown in the below code:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-465 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/esretertdr.png\" alt=\"\" width=\"582\" height=\"367\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/esretertdr.png 582w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/esretertdr-300x189.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/esretertdr-65x41.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/esretertdr-225x142.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/esretertdr-350x221.png 350w\" sizes=\"auto, (max-width: 582px) 100vw, 582px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Output of the above code is shown in following figure:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-466 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/ererererteeeeeeeeeeeeeeeeeeeeeeee.jpg\" alt=\"\" width=\"397\" height=\"119\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/ererererteeeeeeeeeeeeeeeeeeeeeeee.jpg 397w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/ererererteeeeeeeeeeeeeeeeeeeeeeee-300x90.jpg 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/ererererteeeeeeeeeeeeeeeeeeeeeeee-65x19.jpg 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/ererererteeeeeeeeeeeeeeeeeeeeeeee-225x67.jpg 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/ererererteeeeeeeeeeeeeeeeeeeeeeee-350x105.jpg 350w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/p>\n<p>The matrix function accepts arguments like no. of rows, no. of columns, arrangement of elements and data items. These arguments are described in following table:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-467 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-2.png\" alt=\"\" width=\"461\" height=\"179\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-2.png 461w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-2-300x116.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-2-65x25.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-2-225x87.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/Untitled-2-350x136.png 350w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/p>\n<p style=\"text-align: justify;\">A data frame is a two-dimensional array-like structure in which each column contains values of one variable and each row contains for columns. Data frames are used when we want to process data that is available in CSV or Spreadsheet format. Data frames can parse large number of records very quickly. Following are the characteristics required to create a data frame<\/p>\n<ul>\n<li>The column names must be there<\/li>\n<li>The row names should be unique<\/li>\n<li>Each column should contain same number of data items<\/li>\n<\/ul>\n<p>The following code creates a data frame of 6 letters and two columns labelled &#8216;x&#8217; and &#8216;y&#8217;.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-468 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/23242.png\" alt=\"\" width=\"577\" height=\"339\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/23242.png 577w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/23242-300x176.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/23242-65x38.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/23242-225x132.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/23242-350x206.png 350w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-469 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/dddd.jpg\" alt=\"\" width=\"440\" height=\"84\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/dddd.jpg 440w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/dddd-300x57.jpg 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/dddd-65x12.jpg 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/dddd-225x43.jpg 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/dddd-350x67.jpg 350w\" sizes=\"auto, (max-width: 440px) 100vw, 440px\" \/><\/p>\n<p><strong>Datasets<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">For those who do not want to create datasets, R provides inbuilt datasets that can be accessed by command prompt. In most of the standard installations, few datasets are provided by R. Let us see an example of &#8216;mtcars&#8217; dataset that is provided by default in R installations. By typing &#8216;mtcars&#8217; on command prompt, it lists the dataset values as shown in following figure:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-470 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa.jpg\" alt=\"\" width=\"866\" height=\"460\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa.jpg 866w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa-300x159.jpg 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa-768x408.jpg 768w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa-65x35.jpg 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa-225x120.jpg 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/saadsa-350x186.jpg 350w\" sizes=\"auto, (max-width: 866px) 100vw, 866px\" \/><\/p>\n<p>We can create a table of data items form the above mentioned dataset. We can also select or summarize columns as shown in following code:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-471 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/sadsddsfsdfs.png\" alt=\"\" width=\"596\" height=\"233\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/sadsddsfsdfs.png 596w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/sadsddsfsdfs-300x117.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/sadsddsfsdfs-65x25.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/sadsddsfsdfs-225x88.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/sadsddsfsdfs-350x137.png 350w\" sizes=\"auto, (max-width: 596px) 100vw, 596px\" \/><\/p>\n<p><strong>Functions in R<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">R provides a wide variety of functions. Functions can be used for mathematical, statistical, financial calculations. The list of functions provided by R can be browsed using the &#8216;help()&#8217; command on prompt. Let us see how functions can be used in R. The following code shows the use of statistical functions mean and median over an array of numbers.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-473 aligncenter\" src=\"http:\/\/itp7.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/30\/2018\/07\/fgfgg.png\" alt=\"\" width=\"584\" height=\"110\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fgfgg.png 584w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fgfgg-300x57.png 300w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fgfgg-65x12.png 65w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fgfgg-225x42.png 225w, https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-content\/uploads\/sites\/30\/2018\/07\/fgfgg-350x66.png 350w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Let us summarize the key concepts covered in this module<\/p>\n<ul>\n<li>What is the need of R<\/li>\n<li>How to install and use R<\/li>\n<li>Overview of variables and operators<\/li>\n<li>How to use data structures<\/li>\n<li>Overview of functions and packages<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td><strong>you can view video on R Programming &#8211; 1<\/strong><\/td>\n<td><a href=\"https:\/\/youtu.be\/v7S071_mKUo\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>References for R Programming:<\/strong><\/p>\n<ol>\n<li style=\"text-align: justify;\">Felix Alvaro. <em>R\u202f: Easy R programming for beginners, your step-by-step guide to<\/em> <em>learning R programming<\/em>,<\/li>\n<li style=\"text-align: justify;\">John Braun and Duncan James Murdoch. <em>A first course in statistical programming<\/em> <em>with R<\/em>,<\/li>\n<li style=\"text-align: justify;\">John M. Chambers. 2008. <em>Software for data analysis\u202f: programming with R<\/em>, Springer.Michael J. Crawley. <em>The R book<\/em>,<\/li>\n<li style=\"text-align: justify;\">Tilman M. Davies. <em>The book of R\u202f: a first course in programming and statistics<\/em>,<\/li>\n<li style=\"text-align: justify;\">Mark. Gardener. 2012. <em>Beginning R\u202f: the Statistical Programming Language.<\/em>, John Wiley &amp; Sons.<\/li>\n<li style=\"text-align: justify;\">Colin (Colin Stevenson) Gillespie and Robin Lovelace. <em>Efficient R programming\u202f: a<\/em> <em>practical guide to smarter programming<\/em>,<\/li>\n<li style=\"text-align: justify;\">Garrett Grolemund. <em>Hands-on programming with R<\/em>,<\/li>\n<li style=\"text-align: justify;\">Thomas Mailund. <em>Advanced Object-Oriented Programming in R\u202f: Statistical<\/em><em style=\"text-align: initial; font-size: 1em;\">Programing for Data Science, Analysis and Finance<\/em><span style=\"text-align: initial; font-size: 1em;\">,<\/span><\/li>\n<li style=\"text-align: justify;\">Norman S. Matloff. 2011. <em>The art of R programming\u202f: tour of statistical software<\/em> <em>design<\/em>, No Starch Press.<\/li>\n<li style=\"text-align: justify;\">Shuichi Ohsaki, Jori Ruppert-Felsot, and Daisuke Yoshikawa. <em>R programming and its<\/em> <em>applications in financial mathematics<\/em>,<\/li>\n<li style=\"text-align: justify;\">Kun Ren. <em>Modern R programming cookbook\u202f: recipes to simplify your statistical<\/em> <em>applications<\/em>,<\/li>\n<li style=\"text-align: justify;\">Kun Ren. <em>Learning R programming\u202f: become an efficient data scientist with R<\/em>,<\/li>\n<li style=\"text-align: justify;\">Omar. Trejo and Peter. C. Figliozzi. 2017. <em>R Programming By Example Practical,<\/em> <em>hands-on projects to help you get started with R.<\/em>, Packt Publishing.<\/li>\n<li style=\"text-align: justify;\">Alain F. Zuur, Elena N. Ieno, and Erik. Meesters. 2009. <em>A beginner\u2019s guide to R<\/em>, Springer.<\/li>\n<li style=\"text-align: justify;\">Anon. R: The R Project for Statistical Computing. Retrieved March 19, 2017 from https:\/\/www.r-project.org\/<\/li>\n<\/ol>\n","protected":false},"author":4,"menu_order":32,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["mr-hardik-joshi"],"pb_section_license":""},"chapter-type":[],"contributor":[58],"license":[],"class_list":["post-453","chapter","type-chapter","status-publish","hentry","contributor-mr-hardik-joshi"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/users\/4"}],"version-history":[{"count":5,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/453\/revisions"}],"predecessor-version":[{"id":723,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/453\/revisions\/723"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapters\/453\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/media?parent=453"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/pressbooks\/v2\/chapter-type?post=453"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/contributor?post=453"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/itp7\/wp-json\/wp\/v2\/license?post=453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}