Nizamuddin Siddiqui has Published 2268 Articles

How to convert a string vector into an integer vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:34:25

2K+ Views

A string vector contains element inside double-quotes and an integer vector does not have any quotes. Sometimes integer values are stored in double-quotes hence the vector of these values is treated as a string vector in R but we need the integer values to perform mathematical operations. Therefore, we can ... Read More

How to find the mean of a square matrix elements by excluding diagonal elements in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:32:40

302 Views

There are many ways to find the mean of a matrix elements by excluding diagonal elements, this mean is actually the mean of lower triangular matrix and the upper triangular matrix. We can simply use mean function by creating a vector of lower and upper triangular matrix as shown in ... Read More

How to create a bar plot using ggplot2 with one bar having black border in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:28:24

991 Views

The bar plot can be easily created with the help of geom_bar. But if we want to have a different border for a particular bar then we first need to create the bar plot and store it in an object. After that we need to add the original plot with ... Read More

How to reduce a matrix in R to echelon form?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:26:17

1K+ Views

The echelon form of a matrix is the matrix that has the following characteristics:1. The first non-zero element in each row, called the leading entry, is 1.2. Each leading entry is in a column to the right of the leading entry in the previous row.3. Rows with all zero elements, ... Read More

How to remove rows based on blanks in a column from a data frame in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:24:09

5K+ Views

Sometimes data is incorrectly entered into systems and that is the reason we must be careful while doing data cleaning before proceeding to analysis. A data collector or the sampled unit might enter blank to an answer if he or she does not find an appropriate option for the question. ... Read More

How to replace values in a vector with values in the same vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:22:29

1K+ Views

The replacement of values in a vector with the values in the same vector can be done with the help of replace function. The replace function will use the index of the value that needs to be replaced and the index of the value that needs to be placed but ... Read More

How to standardized a column in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:20:54

690 Views

The standardization means converting a vector or column of an R data frame in a way such that the mean of the same becomes 0 and the standard deviation becomes 1, that is it should be converted to standard normal distribution. In R, it can be easily done with the ... Read More

How to create a plot using rgb colors in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:18:50

661 Views

The rgb colors are referred to red green and blue. This combination helps us to create many different colors. In R, we can use rgb function to create a plot using with different colors along with the image function. If we want to have a plot with rgb colors without ... Read More

How to create a random vector in R that sums to 1?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:16:44

648 Views

To create a random vector that sums to 1, we can use uniform distribution. The main thing that needs to be done cautiously is we should include 0 in the vector with randomly generating uniform distribution values. Check out the below examples to understand how it can be done.Example1Live Demo> ... Read More

How to create a plot in base R with mixed font of plot title such as default and italics?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:14:51

251 Views

We sometimes want to highlight the main title of a plot and one of the ways to do it is changing the font of the title to a unique or using a mixed font for the title. If we want to used mixed font then we need to use the ... Read More

Advertisements