A group of statisticians, also known as R Development Core Team, developed R programming and under GNU General Public License 4 distribution. R’s reputation in the field of data science is quite impressive. R programming is quite unique in implementation compared to C, Pascal, Python, Java, and other programming languages.

R Programming Basics

Tools are essential in software development since they can speed up development. Before we dig into the basic syntax, let me discuss the different tools used in R programming. These tools help improve your experience with the programming language in different ways. Here’s the list of tools that are useful in R in no particular order.   

RStudio

  RStudio is one of the most popular tools in R programming. RStudio is an open-source IDE intended for R programming language. It has an impressive UI that allows you to see every detail of the project you’re working on.  Download  

CRAN

CRAN is a network of FTP and web servers that store identical and up-to-date versions of code and documentation for R.  Download  

Caret

Caret is one of the fundamental toolbox in R. Caret allows parallel processing and quickly models neural networks and tree algorithms. Caret’s package includes the following algorithms: Neural networks, Decision trees, Random Forest, AdaBoost, Stochastic gradient, SVM, and other machine learning algorithms.  Download  

Tidyverse

Tidyverse offers another tool needed for data science. It offers unified packages to address the problems in dealing with data. The following are some of the packages that come with Tidyverse to make the process easier:

ggplot2 tidyr purrr tibble dplyr readr

Download  

Simple Hello World

Using RStudio Editor, you can start your first foray into R programming! R programming is not the usual or conventional way type of programming. So, let’s learn the basics!  For a start, here’s a simple hello world program in R.    In the line above, the first line, you can assign “Hello World”  to variable myFristProgram. In the second line, the “Hello World” word prints. The third line is output. In this example, R programming executes in a scripted manner.   

Conditional Statement

Learning the basic syntax in programming is the first step. Another thing that must be learned is using conditional statements and loops. You use conditional statements in order to identify or have an option in a certain scenario. Like any other programming language, R also uses the IF Statement for conditional situations. Here’s the basic or general format of conditional statements using the R programming language:    In the above set of syntax, the IF statement tells R that there are conditions that must be checked and returned TRUE in order to execute the statement underneath, ELSE it will execute once the condition does not satisfy the condition to check.      Output:  “Glass B contains apple juice that belongs to Princess”   In the example above, the first two lines assign values to the variable namely: glass_A and glass_B. The If-statement in the above code identifies which one is greater than the other, the condition glass_A> glass_B, and the machine will evaluate if the values assigned in glass_A is greater than the value of glass_B. Since it is obvious that the value of glass_A is equal to 10 and glass_B is equal to 20, 10 is not greater than 20 which makes the statement false, else then is being executed.  

Using CRAN

First, install the necessary packages from CRAN to get you started. In my case, I use quanteda package.       In the example, data_path is the location of files in my computer that has a package named readtext package.    When I try to execute the code above, here’s the output I gathered:      The data shows a corpus-based text ready for analysis. Aside from corpus-based, quanteda is also capable of Token analysis.      In the code, the first line assigns a corpus in a variable. The variable which contains the corpus is being passed to a token.  

Data Visualization

First things first, you need to install the following in using the package ggplot:  

Tidyverse ggplot2

  Here’s a screenshot of what to expect during installation for both Tidyverse and ggplot2:     After installing the packages and necessary libraries, here’s a simple way of importing CSV file to R programming.      The code below uses ggplot to represent the data in a graphical format.        In this example, different age groups plots in a graphical way. This might not be a good representation, but what I want to emphasize in this article is the usage of ggplot or R programming in general. Using the ggplot package, you can incorporate beautification in your graphs, too. Anyways, there are a lot of packages available that you can explore in CRAN or in R depending on your needs. Furthermore, most of these packages are open source and free. Don’t be afraid to use this resource out; you’ll be amazed at how it improves your programming process!  

R Programming  A step by step tutorial for beginners - 90R Programming  A step by step tutorial for beginners - 58R Programming  A step by step tutorial for beginners - 71R Programming  A step by step tutorial for beginners - 79R Programming  A step by step tutorial for beginners - 3R Programming  A step by step tutorial for beginners - 29R Programming  A step by step tutorial for beginners - 50R Programming  A step by step tutorial for beginners - 12