Nizamuddin Siddiqui has Published 2307 Articles

How to count the number of words in a string in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 06:29:10

440 Views

The number of words in a sentence could be used for text analysis, therefore, we are required to count them. This can be for a single sentence or for multiple sentences. We can find the number of words in a sentence or in multiple sentences using strsplit with sapply.ExampleConsider the ... Read More

How to change plot area margins using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 06:25:51

1K+ Views

While creating plots using ggplot2, the plot area is of square shape but we can change our plot area by setting plot.margin in theme function. This is helpful when we want to decrease the plot area and also when the data points are less.ExampleConsider the below data frame −> set.seed(1) ... Read More

How to select multiple elements of a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 06:23:49

1K+ Views

Generally, a list in R contains a large number of elements and each element can be of different type which is a great thing about lists. Since we can store type of data as a list element therefore storage and selection to different type of data becomes easier. And we ... Read More

How to split a big data frame into smaller ones in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 15:38:43

1K+ Views

Dealing with big data frames is not an easy task therefore we might want to split that into some smaller data frames. These smaller data frames can be extracted from the big one based on some criteria such as for levels of a factor variable or with some other conditions. ... Read More

How to create a polynomial model in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

191 Views

Most of the times the explanatory variables are not linearly related to the response variable and we need to find the best model for our data. In this type of situations, we move on to polynomial models to check whether they will be helpful in determining the accuracy of the ... Read More

How to add a column between columns or after last column in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 15:17:08

166 Views

Since no one is perfect, people might forget to add all columns that are necessary for the analysis but this problem can be solved. If a column is missing in our data frame and we came to know about it later then it can be added easily with the help ... Read More

How to delete a row from an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 15:06:44

419 Views

While doing the analysis, we might come across with data that is not required and we want to delete it. This data can be a whole row or multiple rows. For example, if a row contains values greater than, less than or equal to a certain threshold then it might ... Read More

How to replace missing values recorded with blank spaces in R with NA or any other value?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 14:49:40

919 Views

Sometimes when we read data in R, the missing values are recorded as blank spaces and it is difficult to replace them with any value. The reason behind this is we need to know how many spaces we have used in place of missing values. If we know that then ... Read More

How to find the correlation matrix in R using all variables of a data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 14:42:15

642 Views

Correlation matrix helps us to determine the direction and strength of linear relationship among multiple variables at a time. Therefore, it becomes easy to decide which variables should be used in the linear model and which ones could be dropped. We can find the correlation matrix by simply using cor ... Read More

How to change the order of columns in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Aug-2020 14:32:20

639 Views

Ordering columns might be required when we want to manipulate the data. Manipulation can have several reasons such as cross verification, visualisation, etc. We should also be careful when we change anything in the original data because that might affect our processing. To change the order of columns we can ... Read More

Advertisements