Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 25 of 196

How to round each value to two decimal places in columns if some columns are categorical in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 737 Views

To round each value to two decimal places in columns 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 round each value to two decimal places in columns if some columns are categorical.ExampleCreate the data frameLet’s create a data frame as shown below −Level

Read More

How to check if a set is a subset of another set in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 795 Views

To check if a set is a subset of another set, we can use all function with %in% operator. For example, if we have two vectors say x and y and we want to check whether x is a subset of y then we can use the command given below −all(x %in% y)Check out the below given examples to understand how it works.Example 1To check if a set is a subset of another set in R, use the snippet given below −set_x1

Read More

How to find the length of sequence vector in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 2K+ Views

A sequence vector is created by using the sequence of numbers such as 1 to 15, 21 to 51, 101 to 150, -5 to 10. The length of this type of vectors can be found only by using the length function.For example, if we have a sequence vector say X then the length of X can be found by using the command given below −length(X)Example 1To find the length of sequence vector in R, use the code given below −x1

Read More

How to find the log of each value in columns if some columns are categorical in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 304 Views

To find the log of each value 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 log if some columns are categorical.ExampleCreate the data frameLet’s create a data frame as shown below −Level

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 696 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 command given below −x%o%yCheck out the below examples to understand how it works.Example 1To find the cross product of two vectors in R by adding the elements, use the code given below −x1

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 4K+ 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 position of the X-axis on Y-axis.Check out the Example mentioned below to understand how it can be done.ExampleTo change the position of X-axis in base R plot, use the following command −plot(1:10)OutputIf you execute the above given snippet, it generates the following Output −To create a point chart with X-axis ...

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 549 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) (4,1),(4,2),(4,3),(4,4),(4,5),(4,6) (5,1),(5,2),(5,3),(5,4),(5,5),(5,6) (6,1),(6,2),(6,3),(6,4),(6,5),(6,6)Now, to create the sample space of throwing two dices in R, we can use the below mentioned command −expand.grid(1:6,1:6) ExampleTo create sample space of throwing two dices in R, use the command given below −expand.grid(1:6,1:6)OutputIf you execute the above given command, it generates the following output −  Var1 Var2 1  1   1 2  2   1 3  3   1 4  4   1 5  5   1 6  6   1 7  1   2 8  2   2 9  3   2 10 4   2 11 5   2 12 6   2 13 1   3 14 2   3 15 3   3 16 4   3 17 5   3 18 6   3 19 1   4 20 2   4 21 3   4 22 4   4 23 5   4 24 6   4 25 1   5 26 2   5 27 3   5 28 4   5 29 5   5 30 6   5 31 1   6 32 2   6 33 3   6 34 4   6 35 5   6 36 6   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 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 we want to add rows of df then we can use the command mentioned below −apply(df,1,function(x) x["X"]+x["Y"])Check out the Example given below to understand how it can be done.ExampleFollowing snippet creates a sample data frames: −x1

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 1K+ 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 value in the column.ExampleCreate the data frameLet’s create a data frame as shown below −x

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 149 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 categorical.Example 1Create the data frameLet’s create a data frame as shown below −factor1

Read More
Showing 241–250 of 1,958 articles
« Prev 1 23 24 25 26 27 196 Next »
Advertisements