<div> 
<div tabindex="-1">
<div>
<div>
<div></div>
<div>
<div>
<h1>Rstudio OverView</h1>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>we have 4 panes<br>1) script pan – to write and save the programing script<br>2) Console pane – where all the code will get executed<br>3) Environment/history pane – displays all the variables created,functions<br>used with in the current session<br>4) Helper pane – contains multiple tabs to install/display pacakges,<br>view visualization plots,<br>locate files within the workspace</div>
</div>
</div>
</div>
</div>
<p> </p>
<div>
<div>
<div>In [1]:</div>
<div>
<div>
<div>
<pre>help<span>(</span><span>mean</span><span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>getting and setting workspace</h1>
</div>
</div>
</div>
<div>
<div>
<div>In [2]:</div>
<div>
<div>
<div>
<pre><span># to display current working directory use getwd() function</span><br><span>getwd</span><span>()</span><br></pre>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div></div>
<div>‘C:/Users/Suresh/mlclassscripts’ </div>
</div>
</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre><span># to set up workspace or working directory use setwd() function</span><br><span>#syntax is shown below</span><br><span>setwd</span><span>(</span><span>&quot;path&quot;</span><span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div>In [6]:</div>
<div>
<div>
<div>
<pre><span>setwd</span><span>(</span><span>&quot;C:\\Suresh\\R&amp;D\\Projects\\ML classroom training\\sessions&quot;</span><span>)</span><br><span>setwd</span><span>(</span><span>&quot;C:/Suresh/R&amp;D/Projects/ML classroom training/sessions&quot;</span><span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>getting help in R</h1>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>To get help within R environment, we use help() function to get the<br>documentation<br>for any of the functions/packages available within R environment.<br>To see the arguments required for a function, we use args() function.<br>to see the example of a function, example() function is used.</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre>help<span>(</span><span>&quot;stats&quot;</span><span>)</span><br>help<span>(</span><span>&quot;mean&quot;</span><span>)</span><br><span>args</span><span>(</span><span>&quot;mean&quot;</span><span>)</span><br>example<span>(</span><span>&quot;mean&quot;</span><span>)</span><br><br><span>#getting help documentation for a package</span><br>help<span>(</span>package<span>=</span><span>&quot;caret&quot;</span><span>)</span><br></pre>
<pre><span><a name="more"></a><br></span></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>online help for R programming</h1>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>We can get online help on available packages in R from official website of R-Cran<br><a rel="nofollow" href="https://cran.r-project.org/web/views/" target="_blank">https://cran.r-project.org/web/views/</a></div>
</div>
</div>
<div>
<div></div>
<div>
<div>We can also get online support for our day to day activities from below websites:<br><a rel="nofollow" href="https://stackoverflow.com/" target="_blank">https://stackoverflow.com/</a><br><a rel="nofollow" href="https://stats.stackexchange.com/" target="_blank">https://stats.stackexchange.com</a></div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>Installing Packages</h1>
</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre><span>#install pacakges in R can be done in two ways,</span><br><span>#1) using install.packages() function and from the bottom right pane of Rstudio</span><br>install.packages<span>(</span><span>&quot;randomForest&quot;</span><span>)</span><br><br><span>#loading of installed or downloaded packages can be done using library() function. </span><br><span>#Note that we can only load the package if</span><br><span># we have installed the package already within our R environment</span><br><span>library</span><span>(</span>cluster<span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre><span>#below code to first verify if the library is installed in the R environment, </span><br><span>#if it is not available</span><br><span># then the package will get installed.</span><br><span>if</span><span>(</span><span>!</span><span>library</span><span>(</span>cluster<span>)){</span><br>install.pacakges<span>(</span><span>&quot;cluster&quot;</span><span>)</span><br><span>}</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>basic operations in R</h1>
</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre><span># Adding two numericals</span><br><span>1+1</span><br><br><span>#multiplying two numericals</span><br><span>10</span><span>*</span><span>2</span><br><br><span>#dividing two numericals</span><br><span>10</span><span>/</span><span>2</span><br><br><span>#applying modulus operation on two numericals</span><br><span>10</span><span>%%</span><span>2</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>printing results to R console</h1>
</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre><span>#printing the data on the console</span><br><span>print</span><span>(</span><span>10</span><span>*</span><span>2</span><span>)</span><br><br><span>print</span><span>(</span><span>&quot;data science&quot;</span><span>)</span><br><br><span>print</span><span>(</span><span>pi</span><span>^</span><span>2</span><span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>Variable declaration and assignment in R</h1>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>variable assignment: In the below example, we are creating variable named z:</div>
</div>
</div>
<div>
<div>
<div>In [8]:</div>
<div>
<div>
<div>
<pre>z <span>&lt;-</span>  <span>100</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>we use left arrow or = symbol for variable assignment. Its always good<br>practice to use left arrow for assignment.</div>
</div>
</div>
<div>
<div>
<div>In [9]:</div>
<div>
<div>
<div>
<pre>z <span>=</span> <span>10.009</span><br>z <span>&lt;-</span> <span>10.009</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>Loading existing or default datasets available in R environment</h1>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>we can access default datasets avaiable in R using data() function.<br>data() function will displays all the avaiable datasets within R.</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre>data<span>()</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>In order to load a specific dataset into R, we need to give the dataset name as argument to the data() function</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre>data<span>(</span>AirPassengers<span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>Viewing data of R objects</h1>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>To view first 5 records of a R object (ex:dataframe), we use head() function.<br>head() function expects the data object as argument and prints the first 5 records on the R console.</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre><span>head</span><span>(</span>AirPassengers<span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>to view all the records in a nice tabular view</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre>View<span>(</span>AirPassengers<span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>
<h1>Getting the decription and structure of R object</h1>
</div>
</div>
</div>
<div>
<div></div>
<div>
<div>use str function to see the descriptions of the data object,</div>
</div>
</div>
<div>
<div>
<div>In [ ]:</div>
<div>
<div>
<div>
<pre>str<span>(</span>AirPassengers<span>)</span><br></pre>
</div>
</div>
</div>
</div>
</div>

<div>http://feeds.feedburner.com/DataPerspective</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.dataperspective.info/2017/12/getting-started-with-r.html"> Data Perspective</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/HwNJK0qboWM" height="1"></a></div></div>