Nizamuddin Siddiqui has Published 2303 Articles

How to get row index or column index based on their names in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 08:00:43

823 Views

We might prefer to use row index or column index during the analysis instead of using their numbers, therefore, we can get them with the help of grep function. While dealing with a large data set it becomes helpful because large data sets have large number of rows and columns ... Read More

How to change the Y-axis values in a bar plot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 07:49:09

6K+ Views

Bar plot is frequently used to analyze the number of times a level of factor variable occurs in a data set and the Y-axis values are crucial to the bar plot. Sometimes these values are not in the form we want, therefore, we want to replace them with the new ... Read More

How to extract initial, last, or middle characters from a string in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 07:46:59

2K+ Views

In Text analysis, we might want to extract characters from a single string or from a vector of strings. This extraction might be required to create a new string with some specific words required for further analysis. We can do this with the help of str_sub function of stringr package.ExampleConsider ... Read More

How to convert matrix columns to a list of vectors in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 07:42:45

613 Views

If we want to use columns of a matrix as a vector then we can convert them in a list of vectors. To convert matrix columns to a list of vectors, we first need to convert the matrix to a data frame then we can read it as list. This ... Read More

How to count the number of rows for a combination of categorical variables in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 07:36:38

521 Views

When we have two categorical variables then each of them is likely to have different number of rows for the other variable. This helps us to understand the combinatorial values of those two categorical variables. We can find such type of rows using count function of dplyr package.ExampleConsider the CO2 ... Read More

How to randomize an already created vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 07:17:01

946 Views

Some vectors are randomly created and some are not randomly created in R but we can do randomization for both of these types of vectors. Randomization ensures unbiasedness therefore it is necessary especially when the vector is created with an objective that tends to change the result of the analysis. ... Read More

How to replace NA’s to a value of selected columns in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

678 Views

In data analysis, finding some NA values in a data frame is very common but all the NA values do not create problems if the column that contain NA values is not useful for the analysis. We can replace all NA values to 0 or to any other for the ... Read More

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

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

567 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

Advertisements