Nizamuddin Siddiqui has Published 2307 Articles

How to create an S4 object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:57:01

1K+ Views

To create an S4 object, we can use setClass function where we will pass the object name, column names, and the type of the data that will be stored in the columns. For example, if we want to create an S4 with name data and two numerical columns called by ... Read More

How to subset nth row from an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:55:47

1K+ Views

We can find subsets using many ways in R and the easiest way is to use single-square brackets. If we want to subset a row or a number of consecutive or non-consecutive rows then it can be directly done with the data frame name and the single-square brackets. For example, ... Read More

What are the different types of point available in geom_point of ggplot2 package in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

175 Views

We can create a point chart using ggplot2 package but that point not necessarily to be in circular shape, we have twenty-five shape options for those points in ggplot2. While creating a point chart using ggplot2, we can use shape argument inside geom_point to see the difference among these twenty-five ... Read More

How to perform chi square test for goodness of fit in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

3K+ Views

The chi square test for goodness of fit is a nonparametric test to test whether the observed values that falls into two or more categories follows a particular distribution of not. We can say that it compares the observed proportions with the expected chances. In R, we can perform this ... Read More

How to replace a sub-string with the reverse of that sub-string in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:48:52

75 Views

The chartr function in base R helps us to replace old strings with new strings and hence it can be also used to replace a subs-string with the reverse of that substring. For example, if we have a vector say x that contains tutorialpsoint and we want to convert it ... Read More

How to create a vector of lists in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

364 Views

If we have many lists but we want to use the values in the lists as a vector then we first need to combine those lists and create a vector. This can be done by using unlist function along with the combine function c to create the vector. For example, ... Read More

How to create a histogram with main title in the outer margin of plot window in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

2K+ Views

The main title of a histogram in base R can be inserted by using title function and if we want to have it in the outer margin then outer argument must be set to TRUE. If the outer argument does not fulfil our requirement then we can use par function ... Read More

How to find the group-wise median in an R data.table object?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:42:17

603 Views

When the assumptions of parametric analysis are not satisfied then we move on to non-parametric analysis and non-parametric analysis often deals with the calculation of median because the data is not normally distributed. If we want to find the group-wise median and the data is stored in a data.table object ... Read More

How to convert a matrix into a matrix with single column in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

932 Views

If we have a matrix then we might want to convert it to matrix with single column for some analytical purpose such as multiplying with a vector that has the length equal to the total number of elements as in the matrix. Thus, the matrix can be converted to a ... Read More

How to create smooth density curves without filling densities in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:36:48

336 Views

The density curves can be created by using stat_density function of ggplot2 package but it fills the curve with density hence it becomes difficult to recognize the curves. We can remove these densities by using geom="line" inside the stat_density function so that only the density curves will be plotted.ExampleConsider the ... Read More

Advertisements