Nizamuddin Siddiqui has Published 2307 Articles

How to find the unique combinations of a string vector elements with a fixed size in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:41:55

1K+ Views

A unique combination of vector elements can be found by using combn function with unique function and size argument will help us to identify the size of each of combination. For example, if we have a vector containing string values defined as x then the unique combinations of vector elements ... Read More

How to change the font size of main title of boxplot in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:34:42

4K+ Views

The font size of the main title of boxplot can be changed by defining the font size value using par(cex.main=”size”), here size value can be changed based on our requirement. This needs to be done before creating the boxplot, otherwise, there will be no effect on the size of the ... Read More

How to find the maximum value in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:31:57

1K+ Views

The maximum value is a part of summary statistics and we always need to understand the end limits of our data; therefore, it is highly required. If we have a data frame that contains numerical columns then the maximum value can be found by using max function and the data ... Read More

How to remove column names from an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:26:14

10K+ Views

There are situations when we might want to remove column names such as we want to manually replace the existing column names by new names or we simply don’t want to use them if we are very much familiar with the column characteristics. To remove the columns names we can ... Read More

How to find the position of NA in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:20:00

1K+ Views

When we have NA’s/missing values in an R vector then we want to replace those NA’s and for this purpose we might be needing the position of those values. These positions will be helpful especially in situations when we want to manually replace the missing values. The replacement can be ... Read More

How to check if a matrix is invertible or not in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:15:19

825 Views

If the matrix is singular then it is not invertible and if it is non−singular then it is invertible. Therefore, we can check if a matrix is singular or not. We can use is.singular.matrix function of matrixcalc for this purpose. For example, if we have a matrix called M then ... Read More

How to remove repeated column names in a data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:00:04

297 Views

In data analysis, we sometimes deal with duplicated data or just the representation of the data with same name. One such situation is column names are same for two columns in a data.table object. For this purpose, we can make use of which function with the combination of duplicated function ... Read More

How to find the number of occurrences of unique and repeated characters in a string vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Jan-2021 06:21:42

452 Views

To find the number of occurrences of unique characters in a string vector, we can use table function with the combination of rle and strsplit. For example, if we have a string vector x that contains some unique and repeated values then it can be created by using the below ... Read More

How to set the X-axis labels in histogram using ggplot2 at the center in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Jan-2021 06:14:51

6K+ Views

The boundary argument of geom_histogram function and breaks argument of scale_x_continuous function can help us to set the X-axis labels in histogram using ggplot2 at the center. We need to be careful about choosing the boundary and breaks depending on the scale of the X-axis values. Check out the below ... Read More

How to create horizontal legend using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Jan-2021 06:13:13

5K+ Views

The default legend direction is vertical but it can be changed to horizontal as well and for this purpose we can use legend.direction argument of theme function of ggplot2 package. For example, if we want to create a bar chart with x as categories and y as frequencies tjat are ... Read More

Advertisements