Nizamuddin Siddiqui has Published 2307 Articles

How to create a bar graph using ggplot2 without horizontal gridlines and Y-axes labels in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 08:12:38

328 Views

A bar graph plotted with ggplot function of ggplot2 shows horizontal and vertical gridlines. If we are interested only in the bar heights then we might prefer to remove the horizontal gridlines. In this way, we can have X-axis that helps us to look at the different categories we have ... Read More

How to convert a data frame to data.table in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 08:10:10

969 Views

Since operations with data.table are sometimes faster than the data frames, we might want to convert a data frame to a data.table object. The main difference between data frame and data.table is that data frame is available in the base R but to use data.table we have to install the ... Read More

How to change the axes labels using plot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 11-Aug-2020 08:03:29

246 Views

In a plot, the axes labels help us to understand the range of the variables for which the plot is created. While creating a plot in R using plot function, the axes labels are automatically chosen but we can change them. To do this, firstly we have to remove the ... Read More

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

612 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

5K+ 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

1K+ 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

479 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

387 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

612 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

544 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

Advertisements