Nizamuddin Siddiqui has Published 2307 Articles

How to create a column in an R data frame that contains the multiplication of two columns?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:52:43

2K+ Views

Sometimes we need the multiplication of two columns and create a new column so that the multiplication can be used further for analysis. For example, to calculate BMI we need mass and height and the height is squared, therefore, we would be needing the square of height. For this purpose, ... Read More

How to change the width of whisker lines in a boxplot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:50:59

2K+ Views

In R, by default the whisker lines are as wide as the box of the boxplot but it would be great if we reduce that width or increase it because it will get attention of the viewer in that way. This can be done by using the width argument inside ... Read More

How to find the sum of division in R if zero exists in the vectors?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:49:25

175 Views

To find the sum of division if zero exists in the vectors, we need to assign NA to zeros in both the vectors and then use the sum function with na.rm set to TRUE. For example, if we have two vectors x and y that contains some zeros then we ... Read More

How to identify the difference between Kolmogorov Smirnov test and Chi Square Goodness of fit test in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:48:00

1K+ Views

The Chi Square Goodness of fit test is used to test whether the distribution of nominal variables is same or not as well as for other distribution matches and on the other hand the Kolmogorov Smirnov test is only used to test to the goodness of fit for a continuous ... Read More

How to create boxplot for matrix columns in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:46:07

2K+ Views

To create a boxplot for data frame columns we can simply use boxplot function but it cannot be done directly for matrix columns. If we want to create boxplot for matrix columns then we need to convert the matrix into data frame and then use the boxplot function. For example, ... Read More

How to change data.table object columns value to maximum in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:44:17

122 Views

Sometimes we need to compare the maximum values or set some column of a data frame or data.table object to their maximums, especially in research studies that may require biasedness. Therefore, we can set all the column values to maximum. In case of a data.table object, we can use single ... Read More

How to use mtext function to create the X-axis labels in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:42:25

227 Views

The mtext function can help us to create X-axis or Y-axis labels and we can put these labels to places desired by us with the help of at argument. For example, if we want to use capital letters starting from A to J that are 10 characters on the X-axis ... Read More

How to find the column names and row names from a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:40:59

2K+ Views

The rownames and colnames functions are used to define the corresponding names of a matrix and if we want to extract those names then the same function will be used. For example, if we have a matrix called M that has row names and column names then these names can ... Read More

How to find the p-value using F statistic in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:39:00

1K+ Views

The F statistic has two degrees of freedom, one for the numerator and one for the denominator and the F distribution is a right-tailed distribution. Therefore, we need to use the F-statistic, the degrees of freedoms, and the lower.tail=FALSE argument with pf function to find the p-value for a F ... Read More

How to detach a package in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:37:22

11K+ Views

To detach a package in R, we can simply use the detach function. But we need to remember that once the package will be detached there is no way to use any of the functions of that particular package. We make this mistake if we forget about detachment. For example, ... Read More

Advertisements