Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 121 of 196

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 244 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 lines chart.Example1 Live DemoM1

Read More

How to create polynomial regression model in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 1K+ 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 regression in R, first one is using polym function and second one is using I() function.Example1set.seed(322) x1

Read More

How to create relative frequency table using dplyr in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 707 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 proportional frequency.Example1 Live DemoConsider the below data frame −set.seed(21) x%mutate(freq=n/sum(n)) `summarise()` ungrouping output (override with `.groups` argument) # A tibble: 4 x 3Outputx n freq 1 A 3 0.15 2 B 7 0.35 3 C 7 0.35 4 D 3 0.15 Warning message: `...` is not empty. We ...

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 264 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 of the process five times but it takes the same output all the time then we might want to use only one output.Example1 Live DemoConsider the below data frame −ID

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 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 create the model.Example1 Live Demox1

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 4K+ 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 from 1.ExampleConsider the below data frame −x

Read More

How to create stacked barplot using barplot function in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 468 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 barplot function because bar plots are created for count data only. Here, you will see some examples of count as well as continuous data, carefully read the graphs and understand how the graphs are different from each other.Example1 Live DemoM1

Read More

How to remove rows that contains all zeros in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 9K+ Views

Often, we get missing data and sometimes missing data is filled with zeros if zero is not the actual range for a variable. In this type of situations, we can remove the rows where all the values are zero. For this purpose, we can use rowSums function and if the sum is greater than zero then keep the row otherwise neglect it.Example1 Live DemoConsider the below data frame −set.seed(251) x1

Read More

How to generate the permutation of x values in y positions with fixed row sums in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 175 Views

To generate a permutation of x values in y positions, we can use expand.grid function. For example, if we want to generate three columns for the range of values 0 to 5 then it can be done in R by using the below command − Live Demox

Read More

How to calculate mahalanobis distance in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Nov-2020 723 Views

The Mahalanobis distance is the relative distance between two cases and the centroid, where centroid can be thought of as an overall mean for multivariate data. We can say that the centroid is the multivariate equivalent of mean. If the mahalanobis distance is zero that means both the cases are very same and positive value of mahalanobis distance represents that the distance between the two variables is large. In R, we can use mahalanobis function to find the malanobis distance.Example1 Live DemoConsider the below data frame −set.seed(981) x1

Read More
Showing 1201–1210 of 1,958 articles
« Prev 1 119 120 121 122 123 196 Next »
Advertisements