Nizamuddin Siddiqui has Published 2307 Articles

How to create boxplot for a list object in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 06:31:26

984 Views

A list object can contain multiple elements of data, also the size of the data may vary. If a list object has numerical vectors then the boxplot for each of the elements can be created simply by using boxplot function. For example, if we have a list object called LIST ... Read More

How to change the first value for each group in data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 06:29:14

512 Views

To change the first value for each group in data.table object, we can use single square brackets for accessing and changing the value to desired value. For example, if we have a data.table object called DT that contains a group column defined by Class and a numerical column defined by ... Read More

How to display text in base R plot with 180 degrees rotation?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 06:25:39

1K+ Views

To display text in base R plot with 180 degrees rotation, we can use text function. We would need to define both the axes values for the position where we need the text to be rotated inside the plot. For the rotation of the text, srt argument will be used ... Read More

How to create a plot of binomial distribution in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 06:24:09

1K+ Views

A binomial distribution is based on the distribution of success and failure, the other two parameters of binomial distribution are the sample size and the probability of success. To create a plot of binomial distribution, we first need to define the density of the binomial distribution using dbinom function. The ... Read More

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

969 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

791 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

370 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

774 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

271 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

Advertisements