Nizamuddin Siddiqui has Published 2307 Articles

How to find the cross product of two vectors in R by adding the elements?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:38:00

510 Views

To find the cross product of two vectors in R by adding the elements, we can calculate outer product by using %o% operator.For example, if we have two vectors say x and y then cross product of these two vectors by adding the elements can be found by using the ... Read More

How to change the position of X-axis in base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:37:30

3K+ Views

By default, the position of X-axis is at the bottom and we know that it is always there in all software/programming tools. If we want to change the position of X-axis in base R plot then we can use axis function with pos argument. The pos argument will decide the ... Read More

How to find the absolute maximum of each group in data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:34:20

128 Views

To find the absolute maximum of each group in data.table object in R, we can follow the below steps −First of all, create a data.table object.Then, use summarise_each function of dplyr package along with which.max and abs function to find the absolute maximum of each group after grouping with group_by.Example ... Read More

How to create sample space of throwing two dices in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:33:30

381 Views

When we through two dices the sample space has thirty-six outcomes as shown below −(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6) (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6) (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6) ... Read More

Apply a mathematical operation on rows of an R data frame stored in a list.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:28:31

1K+ Views

To apply a mathematical operation such as multiplication, division, subtraction and addition on rows of an R data frame stored in a list, we can use apply function.For Example, if we have a list called LIST that contains a data frame df with two columns say X and Y and ... Read More

How to remove dot at last position from every value in R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:28:15

862 Views

To remove dot at last position from every value in R data frame column, we can follow the below steps −First of all, create a data frame with a column having dot at last position in every value.Then, use gsub function to remove the dot at last position from every ... Read More

How to find the position of minimum of each numerical column if some columns are categorical in R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:25:43

62 Views

To find the position of minimum of each numerical column if some columns are categorical in R data frame, we can follow the below steps −First of all, create a data frame.Then, use numcolwise function from plyr package to find the minimum of each numerical column if some columns are ... Read More

How change the color of facet title using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:22:07

474 Views

To change the color of facet title using ggplot2 in R, we can use theme function with strip.text.x. argument.For Example, if we have a data frame called df that contains three columns say X, Y and F where F is a factor column then we can create facetted scatterplots between ... Read More

How to multiply corresponding values from two matrices in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:19:48

210 Views

To multiply corresponding values from two matrices in R, we can follow the below steps −First of all, create two matrices.Then, use mapply function to multiply corresponding values from those two matrices.ExampleCreate the first matrixLet’s create a matrix as shown below −M1

Increase the space between facets in a facetted plot created using ggplot2 in R.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:17:43

3K+ Views

To increase the space between facets in a facetted plot created by using ggplot2 in R, we can use theme function with panel.spacing argument.For Example, if we have a data frame called df that contains three columns say X, Y and F where F is a factor column then we ... Read More

Advertisements