Nizamuddin Siddiqui has Published 2307 Articles

How to remove rows in an R data frame using row names?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 09:36:10

12K+ Views

There are a lot of ways to subset an R data frame and sometimes we need to do it by removing rows. In general, the rows are removed by using the row index number but we can do the same by using row names as well. This can be done ... Read More

How to display star/asterisk sign (*) inside a base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:19:07

2K+ Views

To display characters inside a base R plot we can simply use text function with expression and if we want to display an asterisk then we need to put the asterisk within double quotes. For example, if we want to display three stars then only expression(paste("***"))) should be used. Check ... Read More

How to create a bar plot with ggplot2 using stat_summary in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:16:27

780 Views

There are multiple ways to create a bar plot in R and one such way is using stat_summary of ggplot2 package. In this function, we need to supply a function for the y-axis and to create the bars we must use geom="bar". The main thing is to decide which function ... Read More

How to create heatmap in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:14:41

224 Views

A heatmap is a diagrammatic representation of data where the values are represented with colours. Mostly, it is used to display data that has slight variation and applied on matrix data. We can draw it for a full matrix, an upper triangular matrix as well as a lower triangular matrix. ... Read More

How to make the axes widths in a plot wider than default in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:11:23

73 Views

The axes widths are generally very thin in plots but we can make them wider. This will be useful if we want to highlight the axes labels for reasons such as getting attention of the viewer on axes labels etc. To increase the width of the axes in a base ... Read More

What is the difference between na.omit and complete.cases in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:10:11

666 Views

The na.omit function removes all the missing values in a data frame and complete.cases also does the same thing if applied to the whole data frame. The main difference between the two is that complete.cases can be applied to some columns or rows. Check out the below example to understand ... Read More

How to extract the names of list elements in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:07:43

2K+ Views

The names of list elements can be extracted by using the names function. For example, if we have a list defined as List that contains three elements with names element1, element2, and element3 then then these names can be extracted from the List by using the below command:names(List)Example1Live Demo> List1 ... Read More

How to create a heatmap for lower triangular matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:05:37

727 Views

A heatmap is a diagrammatic representation of data where the values are represented with colours. Mostly, it is used to display data that has slight variation. We can draw it for a full matrix, an upper triangular matrix as well as a lower triangular matrix. This can be done with ... Read More

What is the difference between $ and @ in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 06:01:56

247 Views

If we have a data frame defined as df that contains column x, y, and z then extraction of these columns from df can be done by using df$x, df$y, and df$z. On the other hand, if we have an S4 object defined as Data_S4 that contains column x, y, ... Read More

How to remove border of bars from histogram in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:58:53

620 Views

By default, a histogram drawn in base R has black color borders around bars. We might want to remove these black borders to make the histogram visually smooth. This can be done by using lty argument with the hist function. For example, if we have a vector x and we ... Read More

Advertisements