Nizamuddin Siddiqui has Published 2307 Articles

How to sort a matrix based on one column in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:47:38

10K+ Views

Since a matrix contain only numeric values, sorting can be also done for matrices. There might be multiple reasons to sort a matrix such as we want to convert the matrix to a data frame, the data stored in matrix needs to be sorted prior to matrix calculations so that ... Read More

How to generate random samples from different statistical distributions using parameters as a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:45:23

166 Views

To generate random samples from statistical distributions, we use functions like rnorm, rbinom, rexp, rpois for the corresponding distribution based on their names. Using these functions, we can pass their parameters as an argument inside the function. But if we have the parameters saved as a list then generation of ... Read More

How to X-axis labels to the top of the plot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:43:19

3K+ Views

Usually, a plot created in R or any of the statistical analysis software have X-axis labels on the bottom side but we might be interested in showing them at the top of the plot. It can be done for any type of two-dimensional plot whether it is a scatterplot, bar ... Read More

How to find the total number of rows per group combination in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:40:09

267 Views

An R data frame that contains two or more factor columns then there are a greater number of combinations for the number of factors, obviously, if the number of factors is large with large number of levels then the combination of levels of the factors is also large. To find ... Read More

How to remove last few rows from an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:38:37

2K+ Views

An R data frame can contain a very large number of rows and we might want to get rid of some rows if they’re not supposed to be helpful in our data analysis. Therefore, we can remove these rows prior to starting the analysis process. We can say that this ... Read More

How to sort one column of an R data frame in ascending and the other in descending order?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:33:28

250 Views

Sorting of columns of an R data frame is not difficult but sometimes we want to sort them in opposite orders, for example, we might want to sort some columns in ascending order and some in descending order. This variation in sorting purpose makes it a little complicated. Therefore, we ... Read More

How to change the position of the title of a plot which is created using plot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:27:31

1K+ Views

When we create a plot using plot function, the title of the plot appears on top of the plot while using main argument. If we use title function to create the title of the plot then we can adjust its position in many different ways such as any position between ... Read More

How to rescale a continuous variable so that the range of the rescale becomes 0 to 1 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 11:23:03

463 Views

Rescaling a continuous means that we want to standardize it with some properties and if we are using 0 to 1 as a range that represents that property. Most of the times, the objective behind rescaling is we want to nullify the effect of measurement units of the variable under ... Read More

How to write partial title of X-axis in italics using ggplot2 of R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 12:37:06

6K+ Views

Of course, writing axes titles help viewers to understand the plot in a better way because they add more information to the plot. In general, the axes titles have simple font but we can change partial or complete title to italics to get the viewers attraction. This is needed when ... Read More

How to select top rows of an R data frame based on groups of factor column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Aug-2020 12:33:35

233 Views

We use head function to take a look at some top values in an R data frame but it shows the top values for the whole data frame without considering the groups of factor column. Therefore, if we have a large number of values in a particular group then head ... Read More

Advertisements