Nizamuddin Siddiqui has Published 2307 Articles

How to find the index of the last occurrence of repeated values in a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 12:41:25

458 Views

Indexing helps us to understand the location of the value in the vector. If we have a vector that contains repeated values then we might want to figure out the last occurrence of the repeated value. For example, if we have a vector x that contains 1, 1, 2, 1, ... Read More

How to join points in a point chart with lines using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 12:35:08

403 Views

Usually, a point chart is created to assess the relationship or movement of two variables together but sometimes these points are scattered in a way that makes confusion. Hence, data analyst or researcher try to visualize this type of graph by joining the points with lines. In ggplot2, this joining ... Read More

How to generate a normal random vector using the mean of a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 12:32:07

741 Views

To create a normal random vector, we can use rnorm function with mean and standard deviation as well as without passing these arguments. If we have a different vector derived from another distribution or simply represent some numbers then we can use the mean of that vector in the rnorm ... Read More

How to find prime numbers between two values or up to a value in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 12:30:22

905 Views

We know that the prime numbers are the numbers that are not divisible by any number except by themselves or 1 and 1 is not considered as a prime number. In R, we can find the prime numbers up to a number or between two numbers by using Prime function ... Read More

How to find the difference between regression line and the points in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 12:28:47

212 Views

The difference between regression line and the points on the scatterplot are actually the residuals, thus we need to calculate the residual from the model object. This can be simply done by using residuals function. For example, if we create a linear model defined as Model between x and y ... Read More

How to convert rows in an R data frame to list?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 12:18:07

1K+ Views

Sometimes each row needs to be treated differently, therefore, we might want to convert those rows into list. This will help us to perform the operations on our row elements separately. To convert the rows into list, we can use split function by defining the number of rows in the ... Read More

How to combine two matrices to create a block-diagonal matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 12:10:13

616 Views

A block-diagonal matrix means that a matrix added to another matrix at the end the last element. For example, if we have a matrix with nine values and the other matrix also has nine values then the second matrix will be added to the first matrix and the elements below ... Read More

How to find the cube root of negative values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 11:55:32

571 Views

There is no function in R to find the cube root of negative values, hence we need to create that. The code to create the function is as shown below −CubeRoot

How to create side-by-side boxplot in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Oct-2020 11:54:02

313 Views

Often, we need to compare continuous variables using boxplots and thus side-by-side boxplots are required. Creating side-by-side boxplot in base R can be done with the help of creating space for graphs with the help of par(mfrow=). In this function, we can define the number of graphs and the sequence ... Read More

How to create a matrix using vector of string values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Oct-2020 15:40:50

2K+ Views

You might have heard that matrix can contain only numerical values but it is also possible to create a matrix with string values, and of course calculations using these types of matrices would not be possible. To create a matrix using string values, we can first create a vector of ... Read More

Advertisements