Author: Awais
-
How to merge data in R?
1. Using the cbind() function—only if the data frames have the same number of rows, and the records are the same and in the same order: 2. Using the rbind() function to combine the data frames vertically—only if they have an equal number of identically named columns of the same data type and appearing in the same order: 3.…
-
How to aggregate data in R?
To aggregate data in R, we use the aggregate() function. This function has the following essential parameters, in this order:
-
What types of loops exist in R, and what is the syntax of each type?
1. For loop—iterates over a sequence the number of times equal to its length (unless the statements break and/or next are used) and performs the same set of operations on each item of that sequence. This is the most common type of loops. The syntax of a for loop in R is the following: 2. While loop—performs the same set of…
-
How to create a user-defined function in R?
To create a user-defined function in R, we use the keyword function and the following syntax: An example of a simple user-defined function in R:
-
What is R Markdown?
R Markdown is a free and open-source R package that provides an authoring framework for building data science projects. Using it, we can write a single .rmd file that combines narrative, code, and data plots, and then render this file in a selected output format. The main characteristics of R Markdown are:
-
What is RStudio?
RStudio is an open-source IDE (integrated development environment) that is widely used as a graphical front-end for working with the R programming language starting from version 3.0.1. It has many helpful features that make it very popular among R users: To learn more about what RStudio is and how to install it and begin using…
-
What is a factor in R?
A factor in R is a specific data type that accepts categories (aka levels) from a predefined set of possible values. These categories look like characters, but under the hood, they are stored as integers. Often, such categories have an intrinsic order. For example, a column in a data frame that contains the options of…