Nizamuddin Siddiqui has Published 2268 Articles

How to remove duplicate rows in an R data frame if exists in two columns?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 06:21:56

1K+ Views

If two values are repeated in a column that means there are many same values in that column but if those values are repeated in column as well as rows then they are called duplicated rows in two columns. To remove duplicate rows in an R data frame if exists ... Read More

How to display negative labels below bars in barplot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

1K+ Views

Be default, the labels on the plot are represented without sign in a barplot that is created by using ggplot2 but we might want to display the sign of the labels especially in cases where we have some negative values. This can be done with the help of geom_text function ... Read More

How to add a row to a frame from another data frame in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 06:08:41

1K+ Views

Sometimes we want to add new data to original data frame in situations such as we need more data for analysis, looking for comparison between small size and large size data, or some data is missing in the original data and hence need more to be added from other data ... Read More

How to deal with missing column for row names when converting data frame to data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 06:01:56

556 Views

To deal with missing column of row names when converting data frame in R to data.table object, we need to use keep.rownames argument while converting the data frame. For example, if we have a data frame called df that needs to be converted to a data.table object without missing row ... Read More

How to remove the plot margin in base R between the axes and the points inside the plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 05:40:39

1K+ Views

To remove the plot margin in base R between the axes and the points inside the plot, we can use xaxs and yaxs argument in plot function. Depending on the choices of the arguments xaxs and yaxs, the plot region in the respective direction is 4% larger than specified by ... Read More

How to remove rows from an R data frame that contains at least one NaN?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 05:37:52

475 Views

The NA values and NaN values are very different in nature, therefore, removal of rows containing NA values is different from removal of rows containing NaN values. For example, if we have a data frame that has NaN values the rows will be removed by using the is.finite function as ... Read More

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

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

2K+ 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

6K+ 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

4K+ 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

624 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

Advertisements