Nizamuddin Siddiqui has Published 2307 Articles

How to create a line chart using ggplot2 with a vertical line in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 10:40:52

191 Views

In general, the line chart is drawn to view the trend of something and we might also have some threshold point for that trend, for example, if blood pressure is plotted then we might want to show 60 mm Hg as well because this is the lowest acceptable value for ... Read More

How to find the mean of columns of an R data frame or a matrix?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 10:38:38

1K+ Views

If all the columns in an R data frame are numeric then it makes sense to find the mean for each of the columns. This calculation will help us to view how different the values of means are for each of the columns but to make sure that they are ... Read More

How to extract the p-value and F-statistic from aov output in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 10:35:11

4K+ Views

The analysis of variance technique helps us to identify whether there exists a significant mean difference in more than two variables or not. To detect this difference, we either use F-statistic value or p-value. If the F-statistic value is greater than the critical value of F or if p-value is ... Read More

How to collapse factor levels in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 10:33:36

556 Views

Sometimes the levels of a factor are not correctly recorded, for example, recording male with M in some places and with Mal in some places hence there are two levels for level male. Therefore, the number of levels increases if the factor levels are incorrectly recorded and we need to ... Read More

How to convert two columns of an R data frame to a named vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 06:55:29

342 Views

If two columns are of a form such that one column contains the name of the vector values and another column having the values of a vector then we might want to convert them into a vector. To do this, we can simply read the vectors with their data type ... Read More

How to find the maximum using aggregate and get the output with all the columns in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 06:53:39

418 Views

When we use aggregate function to find maximum or any other value, the output of the aggregation does not provide all the columns that corresponds to the maximum value. Therefore, we need to merge the data frame obtained by using aggregate with the original data frame. In this way, we ... Read More

How to join the points of a point chart if X-axis values are categorical in R using ggplot2?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 06:51:42

525 Views

A point chart is usually drawn to see the relationship between two continuous variables and it is also called scatterplot but if the independent variable is categorical then we simply call it a point chart. Often, we want to join or connect the points of a point chart to visually ... Read More

How to remove NULL values from a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 06:45:44

5K+ Views

The value NULL is used to represent an object especially a list of length zero. If a list contains NULL then we might want to replace it with another value or remove it from the list if we do not have any replacement for it. To remove the NULL value ... Read More

How to subtract number of days from a date to get the previous date in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 06:43:32

356 Views

In our daily life, we might want to know what was the date before some number of days. This is also required in professional life, especially in those professions where we work on projects and have tight deadlines. To find the date before a certain number of days we can ... Read More

How to create permutations as a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 06:42:32

368 Views

The permutation is the combination with orders. For example, if we want to create a key for lock with a sequence of numbers then it must be order in some direction, otherwise, it will be difficult to remember and easy to unlock. We can find the permutation of some numbers ... Read More

Advertisements