Nizamuddin Siddiqui has Published 2307 Articles

How to increase the thickness of histogram lines in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

1K+ Views

To increase the thickness of histogram lines in base R, we would need to use par function by defining the thickness size of the line. If we want to do so then line thickness must be defined first before creating the histogram. An example of line size could be lineRead More

How to find the row mean for columns in an R data frame by ignoring missing values?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 05:30:25

5K+ Views

To find the row mean for columns by ignoring missing values, we would need to use rowMeans function with na.rm. For example, if we have a data frame called df that contains five columns and some of the values are missing then the row means will be calculated by using ... Read More

How to deal with error “Error in shapiro.test(…) : sample size must be between 3 and 5000” in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 05:22:48

3K+ Views

The shapiro.test has a restriction in R that it can be applied only up to a sample of size 5000 and the least sample size must be 3. Therefore, we have an alternative hypothesis test called Anderson Darling normality test. To perform this test, we need load nortest package and ... Read More

How to display positive sign for X-axis labels in R using ggplot2?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

365 Views

By default, the positive signs are not displayed in any plot in R. It is well known that if there is no sign seen with any value then it is considered positive, therefore, we do not need the sign but to distinguish between 0 and positive values it could be ... Read More

How to change the size of plots arranged using grid.arrange in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

8K+ Views

To change the size of plots arranged using grid.arrange, we can use heights argument. The heights argument will have a vector equal to the number of plots that we want to arrange inside grid.arrange. The size of the plots will vary depending on the values in this vector.Consider the below ... Read More

How to create a cumulative sum plot in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

3K+ Views

To create a cumulative sum plot in base R, we can simply use plot function. For cumulative sums inside the plot, the cumsum function needs to be used for the variable that has to be summed up with cumulation. For example, if we have two vectors say x and y ... Read More

How to create a plot in base R with tick marks of larger size?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 05:08:48

1K+ Views

To create a plot in base R with tick marks of larger size, we can make use of axis function tck argument. The tck argument value will decide the size of the tick mark but since the ticks lie below the plot area hence the value will have a negative ... Read More

How to find mode for an R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 12:02:06

3K+ Views

To find the model for an R data frame column, we can create a function and use it for the calculation. The function for mode is created as written below −mode

How to change the linetype for geom_vline in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 11:47:16

5K+ Views

To change the linetype for geom_vline, we can use linetype argument in geom_vline function of ggplot2 package. There are mainly six linetypes that can be used and these values are 0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash.Consider the below data frame −x

How to extract all string values from a vector in R with maximum lengths?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 11:44:17

98 Views

If we have a string vector then all the values in the vector are not likely to be of same size and we might be looking for smaller size or bigger size values. Therefore, if we want to extract all string values from a vector in R with maximum lengths ... Read More

Advertisements