Nizamuddin Siddiqui has Published 2307 Articles

What is the equivalent of sumproduct function of Excel for two vectors in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 12:02:35

2K+ Views

The sumproduct function in Excel multiply each value of two or more arrays with the corresponding values then add the sum of the result. For example, if we have 1, 2 in A1, A2 in Excel and 2, 2 in B1 and B2 then sumproduct will multiply 1*2 and 2*2 ... Read More

How to reverse the X-axis labels of scatterplot created by using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 11:58:11

823 Views

ExampleThere exists a possibility that one of the variables is recorded in an opposite manner and we want to create a scatterplot using that variable. Therefore, we would need to reverse that variable while plotting. Suppose that variable is an independent variable, hence it will be plotted on X-axis. Thus, ... Read More

How to calculate weighted mean in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 11:50:08

7K+ Views

Weighted mean is the average which is determined by finding the sum of the products of weights and the values then dividing this sum by the sum of total weights. If the weights are in proportion then the total sum of the weights should be 1. In base R, we ... Read More

How to change the adjustment of the plot title using ggplot2 to align it above the Y-axis labels in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 11:26:38

499 Views

When we create a plot and put a title above it, the alignment of the title is left-adjusted by default and that lies on the edge of the plot area. But sometimes, we want to display the title on the above side of the Y-axis labels, therefore, we can use ... Read More

How to create bar plot of means with error bars of standard deviations using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 11:19:25

400 Views

If we have summary data for a group variable then we might want to look at the errors or say differences between mean and standard deviations visually, therefore, we can create a bar plot with error bars of standard deviations. This can be done by using geom_errorbar function of ggplot2 ... Read More

How to add a vertical line with some value on a scatterplot created by ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 11:09:54

393 Views

When we draw a scatterplot, there might be some crucial points that we would want to display, hence we create a vertical or horizontal based on our objective. These vertical or horizontal lines can be drawn by using geom_vline or geom_hline function of ggplot2 but to add some value with ... Read More

How to create a bar plot using ggplot2 with percentage on Y-axis in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 11:06:57

2K+ Views

Mostly, the bar plot is created with frequency or count on the Y-axis in any way, whether it is manual or by using any software or programming language but sometimes we want to use percentages. It can be done by using scales package in R, that gives us the option ... Read More

How to replace a value in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 11:02:04

8K+ Views

To replace a value in an R vector, we can use replace function. It is better to save the replacement with a new object, even if you name that new object same as the original, otherwise the replacements will not work with further analysis. As you can see in the ... Read More

How to add a new column in an R data frame with count based on factor column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 10:54:26

3K+ Views

While doing the data analysis, often we have to deal with factor data and we might want to find the frequency or count of a level of factor and the other variable combination. This helps us to make comparison within and between factor levels. Therefore, we can add a new ... Read More

How to create cumulative sum chart with count on Y-axis in R using ggplot2?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 10:43:14

1K+ Views

Cumulative sums are often used to display the running totals of values and these sums also help us to identify the overall total. In this way, we can analyze the variation in the running totals over time. To create the cumulative sum chart with count on Y-axis we can use ... Read More

Advertisements