Nizamuddin Siddiqui has Published 2307 Articles

How to create a plot for the response variable grouped by two columns using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 13:38:28

92 Views

When two categorical variables make an impact on the response variable together then it is necessary to visualize their effect graphically because this graph helps us to understand the variation in the effect. Therefore, we can create a plot for the response variable that changes with one or both of ... Read More

How to create a subset of rows or columns of a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 13:26:10

1K+ Views

A matrix can have multiple rows and columns like a data frame. As in data frames, we sometimes require to take subsets, the same might be required with matrices. But subsetting matrices data is quite simple as compared to subsetting a data frame.ExampleConsider the below matrix −> M M [, ... Read More

How to join two data frames based one factor column with different levels and the name of the columns in R using dplyr?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 13:20:59

422 Views

When there is a common factor with different levels, the joining of data frames is possible but the result will present all the levels with dplyr. We can make use of left_join function to join the two data frames but the size of the first data frame must be greater ... Read More

How to select top or bottom n elements of a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 13:17:06

453 Views

Selection of top or bottom elements can be done with the help of head and tail function in R. It is required when we want to understand the data in a vector or perform some calculation for partial data.ExampleConsider the below vectors, we will use head and tail to select ... Read More

How to access elements of nested lists in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 13:15:25

3K+ Views

Sometimes the lists are contained in another list but we want to access the nested list’s elements. Since these elements are part of a list then cannot be directly accessed, first we need to access the broader list and then the list that contains the element to reach the actual ... Read More

How to increase the printing limit in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 13:14:02

2K+ Views

When we deal with large data then the problem of printing the data or output of the analysis arises. Due to this problem, it becomes difficult to have a look at our complete but it can be avoided. Before importing any large data or performing any calculation that may result ... Read More

How to change the aspect ratio of a plot in ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 12:30:46

6K+ Views

The aspect ratio of a chart can be changed in ggplot2 and this will be useful if we want a smaller image of the chart. Sometimes, we don’t have large space where the chart will be pasted therefore this functionality becomes useful. Mostly, in research reports we see charts that ... Read More

How to deal with warning “removed n rows containing missing values” while using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 12:16:43

16K+ Views

The warning “removed n rows containing missing values” occurs when we incorrectly specify the range of the values for X-axis or Y-axis. We can this range in ggplot function using scale_x_continuous(limits=c(?, ?)) for x axis and scale_y_continuous(limits=c(?, ?)) for y axis. If the range will be larger than the actual ... Read More

How to create a bar chart using ggplot2 with facets that are in the order of the data in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 12:01:51

2K+ Views

Since visualization is an essential part of data analysis, we should make sure that the plots are created in a form that is easily readable for users. For this purpose, the facets in a bar chart helps us to understand the factor variable levels for another factor. To create such ... Read More

How to stop printing messages while loading a package in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 11:59:32

173 Views

There are some annoying messages we get while loading a package in R and they are not useful until and unless we are not loading a new package. Since these messages looks like outputs they might be confusing especially when we are analysing string data. Therefore, we must get rid ... Read More

Advertisements