Nizamuddin Siddiqui has Published 2307 Articles

How to create a character vector from data frame values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:44:12

3K+ Views

To create a character vector in R we can enclose the vector values in double quotation marks but if we want to use a data frame values to create a character vector then as.character function can be used. For example, if we have a data frame df then all the ... Read More

How to create multiple lines chart with unique line types in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:43:19

125 Views

Line types can be very different and they are helpful to differentiate among different variables. Mostly, it is used to plot trend data so that the trend for different variables can be visualized with a unique line. In R, we can use matplot function to create such type of multiple ... Read More

How to create polynomial regression model in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:41:05

844 Views

A Polynomial regression model is the type of model in which the dependent variable does not have linear relationship with the independent variables rather they have nth degree relationship. For example, a dependent variable x can depend on an independent variable y-square. There are two ways to create a polynomial ... Read More

How to create relative frequency table using dplyr in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:39:45

525 Views

The relative frequency is the proportion of something out of total. For example, if we have 5 bananas, 6 guava, 10 pomegranates then the relative frequency of banana would be 5 divided by the total sum of 5, 6, and 10 that is 21 hence it can be also called ... Read More

How to create stacked barplot using barplot function with each bar having unique color in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:38:35

306 Views

In a bar plot, each bar represents one category of a single categorical variable but in a stacked bar plot, the bars represent same categorical variable but each divided into sub-categories. If we want to have similar distribution of colors in each bar then col argument with barplot function can ... Read More

How to remove continuously repeated duplicates in an R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:35:37

140 Views

Often values are repeated that generate duplication in the data and we might want to get rid of those values if they are not likely to create bias in the output of the analysis. For example, if we have a column that defines a process and we take the output ... Read More

How to extract the model equation from model object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:33:15

2K+ Views

To extract the model equation model object, we can use the model object name with dollar sign and call function. For example, if we have a model object name Model then the model equation can be extracted by using Model$call. This will directly present the equation that was used to ... Read More

How to set the chart title at the bottom using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:31:50

1K+ Views

Generally, the chart title is written on the upper side of the plot but sometimes we need to put it in the bottom. This is recommended in situations when the chart title explains something about the plot. For example, if we are plotting a normal distribution then we can use ... Read More

How to change the thickness of the borders of bars in bar plot created by using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:29:58

3K+ Views

The border thickness highlights the bars and this could be useful in situations where we have similar frequencies. If we want to change the thickness of the bars then size argument under geom_bar function of ggplot2 package can be used and it can be set according to our need starting ... Read More

How to create stacked barplot using barplot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Nov-2020 11:28:12

327 Views

To create a stacked barplot using barplot function we need to use matrix instead of a data frame object because in R barplot function can be used for a vector or for a matrix only. We must be very careful if we want to create a stacked bar plot using ... Read More

Advertisements