Nizamuddin Siddiqui has Published 2307 Articles

How to create stacked bar plot in which each bar sum to 1 or 100% in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 12:14:30

272 Views

A stacked bar plot consists multiple bars in one bar, it shows one category for a categorical variable with its levels. Mostly, the stacked bar chart is created with the count of the levels in each category but if we want to create it with percentage for individual categories of ... Read More

How to create a lagged variable in R for groups?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 12:11:53

372 Views

Lagged variable is the type of variable that contains the previous value of the variable for which we want to create the lagged variable and the first value is neglected. Therefore, we will always have one missing value in each of the groups, if we are creating a lagged variable ... Read More

How to multiple a matrix rows in R with a vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 12:08:19

453 Views

When we multiple a matrix with a vector in R, the multiplication is done by column but if we want to do it with rows then we can use transpose function. We can multiply the transpose of the matrix with the vector and then take the transpose of that multiplication ... Read More

How to create a vector with names of its elements in one line code in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 12:00:39

688 Views

Vectors are frequently created in R but most of the times we don’t give names to their elements and if we want to give their names then we can use setNames function. This function will help us to name the vector elements in a single line of code, obviously this ... Read More

How to plot a function with ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 11:57:00

4K+ Views

Plotting a function is very easy with curve function but we can do it with ggplot2 as well. Since ggplot2 provides a better-looking plot, it is common to use it for plotting instead of other plotting functions. To plot a function, we should specify the function under stat_function in ggplot.ExampleConsider ... Read More

How to change the color of lines for a line chart using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 11:54:25

742 Views

When we create line chart with each of the lines having different color, we might want to change the color of lines if the colors we used at the first time are not making the chart attractive. This can be done by manually setting the color of the lines in ... Read More

How to view saved Rdata file in windows?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 11:50:46

1K+ Views

We save our data files created in R to use them in the future and these files have an extension .Rdata. To view these files, we can make use of load function that will read the path of the file on your system. Suppose you save the file in Documents ... Read More

How to plot a function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 10:05:20

404 Views

Plotting a function in R is not a difficult task. We can do it simply with curve function but if the function is very complex then it inside curve function might be difficult. It totally depends on the understand of the person who wants to plot the function, if he ... Read More

How to filter column values for some strings from an R data frame using dplyr?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 10:00:32

222 Views

Filtering data helps us to make desired groups of data than can be further used for analysis. In this way, accuracy can be achieved and computation becomes easy. Suppose, we have a homogeneous group then to partition that group based on some characteristics the filter function of dplyr package can ... Read More

How to find the unique rows based on some columns in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Aug-2020 09:55:01

366 Views

Especially when the experimental conditions are same then we expect some of the row values for some columns to be the same, it is also done on purpose while designing the experiments to check the fixed effect of variables. If we want to determine the unique rows then it can ... Read More

Advertisements