Nizamuddin Siddiqui has Published 2307 Articles

Find the unique pair combinations of an R data frame column values.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 05:48:46

1K+ Views

To find the unique pair combinations of an R data frame column values, we can use combn function along with unique function.For Example, if we have a data frame called df that contains a column say x then we can find the unique pair combinations of all column values by ... Read More

Create a random sample by ignoring missing values in an R vector.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 05:41:52

266 Views

To create a random sample by ignoring missing values in an R vector, we can use sample function and the negation of is.na with vector name.For Example, if we have a vector called X that contains some NAs then we can create a random sample of size 100 of X ... Read More

How to check which value is NA in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 05:37:48

14K+ Views

To check which value in NA in an R data frame, we can use apply function along with is.na function.For Example, if we have a data frame called df that contains some NA values then we can check which value is NA by using the command mentioned below −apply(df, 2, ... Read More

Find the frequency of non-NA values in each row of an R dataframe.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 05:30:50

194 Views

To find the frequency of non-NA values in each row of an R data frame, we can use apply function along with na.omit function.For Example, if we have a data frame called df that contains some NA values then we can find the frequency of non-NA values in each row ... Read More

How to find the row sums if NA exists in the R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 05:15:03

4K+ Views

To find the row sums if NA exists in the R data frame, we can use rowSums function and set the na.rm argument to TRUE and this argument will remove NA values before calculating the row sums.For Example, if we have a data frame called df that contains some NA ... Read More

How to add zero before a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 05:04:49

424 Views

To add zero before a vector in R, we can simply use rep function and provide the number times we want to have zero in the vector.For Example, if we have a vector called X that contains three values say 1, 2, 3 and we want to add three zeros ... Read More

Fill bars in a base R barplot with colors based on frequency.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 05:00:31

374 Views

Suppose we have a vector that contains only frequencies and we want to create a bar chart in base R using these frequencies with color of bars based on frequencies, therefore, we can use barplot function and providing the color of the bars with as shown in the below ExamplesThe ... Read More

How to create a circle filled with a color in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Nov-2021 12:07:41

655 Views

We can create a circle in R by using draw.circle function of plotrix package and default color of the circle is white. If we want to change the color of a circle then we can use col argument and pass the desired colors.For Example, if we want to create a ... Read More

How to change a text value in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Nov-2021 11:57:50

3K+ Views

To change a text value in an R data frame, we can simply use replace function.For Example, if we have a data frame called df that contains a column say Names and one of the names say Raj is misspelled as Raaj then we can replace Raaj with Raj by ... Read More

How to find mathematical set using a data frame column in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Nov-2021 11:45:44

61 Views

A mathematical set is a collection of unique elements or a collection of elements that are different from each other. If we want to find a mathematical set using a data frame column then we can simply use unique function.For Example, if we have a data frame called df that ... Read More

Advertisements