Nizamuddin Siddiqui has Published 2307 Articles

How to create a column with ratio of two columns in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2021 05:27:06

2K+ Views

To create a new column with ratio of two columns in an R data frame, we can use division sign.For example, if we have a data frame called df that contains two columns say X and Y and we want to create a new column with ratio of X and ... Read More

How to find the number of times a variable changes its sign in an R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2021 05:22:20

363 Views

To find the number of times a variable changes its sign in an R data frame column, we can use sign function with diff and sum function.For example, if we have a data frame called df that contains a column say C then, we can find the number of times ... Read More

How to change the color of line in xyplot in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:22:10

347 Views

To change the color of line in xyplot, we can use col argument.For example, if we have two vectors say X and Y and we want to create a red colored xyplot between X and Y then we can use the following command −xyplot(x~y, type="l", col="red")Check out the below example ... Read More

How to fill the outliers with different color in base R boxplot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:21:09

1K+ Views

To fill the outliers in boxplot with different color in base R, we can use outpch argument for the shape and outbg argument for colors.For example, if we have a vector called X that contains some outliers then we can create a boxplot of X with different color outliers by ... Read More

How to display outliers in boxplot with different shape in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:19:41

445 Views

To display outliers in boxplot with different shape in base R, we can use outpch argument in boxplot.For example, if we have a vector called X that contains some outliers then we can create a boxplot of X with different shape of outliers by using the below given command −boxplot(X, ... Read More

How to change the color of box of boxplot in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:18:04

12K+ Views

To change the color of box of boxplot in base R, we can use col argument inside boxplot function.For example, if we have a vector called V and we want to create a boxplot of V without red colored box then we can use the following command −boxplot(x, col="red")ExampleTo change ... Read More

How to change the color of outliers in base R boxplot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:16:26

2K+ Views

To change the color of outliers in base R boxplot, we can use outcol argument in boxplot function.For example, if we have a vector called X that contains some outliers then we can create a boxplot of X with blue color outliers by using the below given command −boxplot(X, outcol="red")ExampleTo ... Read More

How to write plot description outside plot in facetted plot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:14:29

376 Views

To write plot description outside plot using ggplot2, we can use annotate function and coord_cartesian function. The annotate function will define the plot description and the coord_cartesian function will define the position of the text outside the plot area.Check out the below given example to understand how it works.ExampleFollowing snippet ... Read More

How to test if strings stored in a vector are present in an R list?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:11:43

76 Views

To test if strings stored in a vector are present in an R list or not, we can use mapply function. For example, if we have a vector of strings say V and a list called LIST then we can check whether elements in V are present in LIST by ... Read More

Find the frequency of successive occurrences less than equal to a threshold in an R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 22-Nov-2021 08:09:28

177 Views

To find the frequency of successive occurrences less than a threshold value in an R data frame column, we can use rle function along with sum function.Check out the below given examples to understand how it can be done.Example 1Following snippet creates a sample data frame −x

Advertisements