Nizamuddin Siddiqui has Published 2307 Articles

How to find similar words in vector of strings in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Sep-2020 07:43:16

988 Views

Sometimes strings in a vector of strings have spelling errors and we want to extract the similar words to avoid that spelling error because similar words are likely to represent the correct and incorrect form of a word. This can be done by using agrep with lapply function.Example 1 Live Demox1Read More

How to change the scale of Y-axis if the histogram bars are higher than the axis size in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Sep-2020 07:31:33

2K+ Views

When we create a histogram using hist function in R, often the Y-axis labels are smaller than the one or more bars of the histogram. Therefore, the histogram does not look appealing and it becomes a little difficult to match the Y-axis values with the bars size.To solve this problem, ... Read More

How to find the number of values in a column of an R data frame that are not zero?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:57:37

184 Views

If an R data frame has numerical columns then it is also possible that there exist zeros in few or all columns and we might be interested in finding the number of non-zero values in a column. This will help us to compare the columns based on the number on ... Read More

How to avoid the warning “Cannot compute exact p-value with ties” while perform correlation test for Spearman’s correlation in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:45:45

16K+ Views

When the variables are not continuous but could be ranked then we do not use pearson correlation coefficient to find the linear relationship, in this case spearman correlation coefficient comes into the scene. Since the spearman correlation coefficient considers the rank of values, the correlation test ignores the same ranks ... Read More

How to get row index based on a value of an R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:43:24

4K+ Views

A row of an R data frame can have multiple ways in columns and these values can be numerical, logical, string etc. It is easy to find the values based on row numbers but finding the row numbers based on a value is different. If we want to find the ... Read More

How to display mean inside boxplot created by using boxplot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:30:54

582 Views

A boxplot shows the median as a measure of center along with other values but we might want to compare the means as well. Therefore, showing mean with a point is likely to be preferred if we want to compare many boxplots. This can be done by using points(mean(“Vector_name”)), if ... Read More

How to find the mean of all values in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:26:29

2K+ Views

If a data frame has all numerical columns then we might be interested in finding the mean of all values in that data frame but this cannot be done directly because a data frame object is not numeric. Therefore, to find the mean of all values in an R data ... Read More

How to find the quantiles in R without quantile name?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:15:28

795 Views

The calculation of quantiles in R is very simple, we just need to use quantile function and it returns all the quantiles that are 0%, 25%, 50%, 75% and 100%. If we want to avoid the printing the name of these quantiles then we can use names=FALSE with the quantile ... Read More

How to create a matrix with random values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:11:16

7K+ Views

Generally, a matrix is created with given values but if we want to create the matrix with random values then we will use the usual method with the matrix function. Random selection in R can be done in many ways depending on our objective, for example, if we want to ... Read More

How to combine matrices having same number of columns in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:56:09

254 Views

The matrices that have same number of columns can be combined by rows. For example, if we have five matrices list, each having six columns then those matrices can be converted into a single matric by joining the rows of those matrices. It can be done by using do.call(rbind, ”List_of_matrices_object_name”).ExampleConsider ... Read More

Advertisements