Nizamuddin Siddiqui has Published 2307 Articles

How to increase the space between horizontal legends using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 09:58:35

484 Views

Generally, the space between two legend entries is not large enough and it becomes difficult to read the legend names if the names are long. In this case, we need to increase the margin between the legend entries/names but this would be required when the legends are horizontally aligned as ... Read More

How to add a row in an R data frame at a specific place?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 09:53:56

389 Views

The data collected for the first time is utilised as it is but when we need to go for secondary data to conduct the same or similar study again, we can use new data as well as the primary data. In this type of situations, we might want to randomly ... Read More

How to create three-dimensional arrays of different sizes in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:22:32

720 Views

A three-dimensional array can have matrices of different size and they are not necessarily to be square or rectangular. Also, all the elements in an array are of same data type. To create a three-dimensional array of different size we would need to use the proper number of rows and ... Read More

How to find percentile rank for groups in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:18:34

837 Views

The word percentile means the percentage that falls below or above the percentile value. For example, if we have a value that lies at 50th percentile then we would say 50 percent of the values lies below or above that value. The value 50 here is called the percentile rank. ... Read More

How to combine vectors of equal length into a list with corresponding elements representing a single element of the list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:14:15

320 Views

To combine three vectors into a list with corresponding elements representing a single element of the list we can use mapply function. For example, if we have three vectors x, y, and z each having number of elements equal to one-hundred then the list with corresponding elements can be created ... Read More

How to perform tukey HSD in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:12:32

806 Views

First thing you must remember while moving on to post hoc analysis is the null hypothesis of the analysis of variance must be rejected, so that we can claim there exists a difference in the group means. Now, once we achieve that the tukey HSD can be performed simply by ... Read More

What is the shortest way to round to the integer value in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:09:59

68 Views

The shortest way to round to the integer value is using trunc function. The trunc function is used to return the largest integer that is smaller than or equal to the actual value, that means it rounds downs to the nearest integer. It works as a ceiling function for negative ... Read More

How to create a plot of quadratic regression with fitted values against X in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:08:08

145 Views

The quadratic regression model can be plotted by using the plot function but we would need to find the fitted values using the model and this can be done with the help of fitted function. For example, if we have a quadratic model M and the data has an independent ... Read More

How to create a plot in base R with dates sequence on X-axis?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:05:33

1K+ Views

If we have a vector that contains dates as sequence that needs to be plotted on the X-axis and another vector for the response then the plot can be simply created by using the plot function. In the plot function, we would need to pass the dates as the first ... Read More

How to create a plot with dashed regression line in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Dec-2020 07:02:21

699 Views

To create a regression line in base R, we use abline function after creating the scatterplot but if we want to have the line dash format then lty argument must also be used with value equals to 2 after defining the regression model inside abline. For example, if we have ... Read More

Advertisements