Nizamuddin Siddiqui has Published 2307 Articles

How to create a dashed line that passes through Y = 1 in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:31:36

1K+ Views

Usually, plots are created with solid lines but sometimes we need to use dashed line so that the points can represent a threshold or something critical, the main objective here is to get the attention of the reader on these points. In base R, the plots are created with plot ... Read More

How to create a dendrogram without X-axis labels in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:27:49

423 Views

A dendrogram display the hierarchical relationship between objects and it is created by using hierarchical clustering. In base R, we can use hclust function to create the clusters and the plot function can be used to create the dendrogram. For example, if we want to create the dendrogram for mtcars ... Read More

How to create a random sample of values between 0 and 1 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:23:52

3K+ Views

The continuous uniform distribution can take values between 0 and 1 in R if the range is not defined. To create a random sample of continuous uniform distribution we can use runif function, if we will not pass the minimum and maximum values the default will be 0 and 1 ... Read More

How to find the combination of multiplication of integers up to a certain value in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:23:03

153 Views

Suppose we want to find the total number of combinations of two numbers, say, 1 and 2 and then multiply each of the combination values. This will result in the following combinations −1 1 1 2 2 1 2 2And the multiplication will also have a third column as shown ... Read More

How to convert MANOVA data frame for two-dependent variables into a count table in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:21:54

151 Views

MANOVA refers to multivariate analysis of variance, in this method we have more than one dependent variable and multiple independent variables. We want to compare each level of the independent variable combination for each of the dependent variables. To convert MANOVA data frame for two-dependent variables into a count table, ... Read More

How to replace “and” in a string with “&” in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:06:51

119 Views

We know that the word “and” can be written as “&”. If we have vectors that contain string values separated with word “and” then we can replace it with “&”. To do this, we can use stri_replace_last function of stringi package. For example, if we have a string vector that ... Read More

How to create a random sample of months in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:03:02

303 Views

Random samples can be created by using sample function and months in a year can be generated with the help of month.name function. Therefore, if we want to create a random sample of months then month.name can be used with sample function as sample(month.name) and if the size of the ... Read More

How to subset a data frame by excluding a specific text value in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 13:02:02

657 Views

To create a subset based on text value we can use rowSums function by defining the sums for the text equal to zero, this will help us to drop all the rows that contains that specific text value. For example, if we have a data frame df that contains A ... Read More

How to highlight text inside a plot created by ggplot2 using a box in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 12:56:07

185 Views

There might be many ways to highlight text inside a plot but the easiest one would be using geom_label function of ggplot2 package, with the help of this function we can put the required text and the aesthetics of that text by using a single line of code. It is ... Read More

How to calculate the sensitivity and specificity from a confusion matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Nov-2020 12:48:06

2K+ Views

If we have a confusion matrix then the sensitivity and specificity can be calculated using confusionMatrix function of caret package. For example, if we have a contingency table named as table then we can use the code confusionMatrix(table). This will return sensitivity and specificity as well as many other metrics.Example1Live ... Read More

Advertisements