Nizamuddin Siddiqui has Published 2307 Articles

How to select rows of a data frame that are not in other data frame in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 12:04:21

2K+ Views

Instead of finding the common rows, sometimes we need to find the uncommon rows between two data frames. It is mostly used when we expect that a large number of rows are uncommon instead of few ones. We can do this by using the negation operator which is represented by ... Read More

How to check whether the elements of a vector are arranged in an increasing order or decreasing order?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 11:53:03

689 Views

A vector can contain values that are increasing or decreasing in nature or they can be also random which means a higher value may come after a lower one which is followed by a higher value. An example of increasing arrangement of elements of vector is 1, 2, 3 and ... Read More

How to extract strings based on first character from a vector of strings in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 11:20:54

245 Views

Sometimes a vector strings have patterns and sometimes we need to make patterns from a vector of strings based on the characters. For example, we might want to extract the states name of United States of America from a vector that contains all the names. This can be done by ... Read More

How to find the difference of values of each row from previous by group in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 11:11:23

1K+ Views

In Data Analysis, sometimes we need to find the difference of the current value from the previous value and it can be also needed for groups. It helps us to compare the differences among the values. In R, we can use dplyr package’s group_by and mutate function with lag.ExampleConsider the ... Read More

How to find the number of columns of an R data frame that satisfies a condition based on row values?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 11:07:15

639 Views

Sometimes we want to extract the count from the data frame and that count could be the number of columns that have same characteristics based on row values. For example, if we have a data frame containing three columns with fifty rows and the values are integers between 1 and ... Read More

How to solve the simultaneous linear equations in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 11:01:36

1K+ Views

The data in simultaneous equations can be read as matrix and then we can solve those matrices to find the value of the variables. For example, if we have three equations as −x + y + z = 6 3x + 2y + 4z = 9 2x + 2y – ... Read More

How to change the gridlines of Y-axis on a chart created by using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 10:56:55

159 Views

Normally, the gridlines on a plot created by using ggplot2 package are a little far from each other but sometimes the plot looks better if the gridlines are close to each other, therefore, we might want to do so. This can be done by setting the minor_breaks and breaks using ... Read More

How to find standard deviations for all columns of an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 10:54:38

7K+ Views

To find the means of all columns in an R data frame, we can simply use colMeans function and it returns the mean. But for standard deviations, we do not have any direct function that can be used; therefore, we can use sd with apply and reference the columns to ... Read More

How to change the row index after sampling an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 10:51:39

675 Views

When we take a random sample from an R data frame the sample rows have row numbers as in the original data frame, obviously it happens due to randomization. But it might create confusion while doing analysis, especially in cases when we need to use rows, therefore, we can convert ... Read More

How to find the n number of largest values in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 10:48:34

165 Views

A vector may have thousands of values and each of them could be different or same also. It is also possible that values can be grouped or randomly selected but having few similar values. Irrespective of the values in a vector, to find some largest values we need to sort ... Read More

Advertisements