Found 2038 Articles for R Programming

How to create NA column for a contingency table in R?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:44:51

332 Views

To create NA column for a contingency table in R, we can follow the below steps −First of all, create a data frame with two columns having some NA values.Create a contingency table for two columns.Create the same table using useNA.Create the data frameLet's create a data frame as shown below − Live Demox

How to find the confusion matrix for linear discriminant analysis in R?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:43:34

1K+ Views

To find the confusion matrix for linear discriminant analysis in R, we can follow the below steps −First of all, create a data frame.Create new features using linear discriminant analysis.Find the confusion matrix for linear discriminant analysis using table and predict function.Create the data frameLet's create a data frame as shown below − Live DemoGroup

How to apply different function to grouping values in an R data frame?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:41:59

126 Views

To apply different function to grouping values in an R data frame, we can follow the below steps −First of all, create a data frame.Then, use ifelse function to apply different function to grouping values.Create the data frameLet's create a data frame as shown below − Live Demox

How to find the starting position for consecutive values given the length of consecutive values in an R vector?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:40:31

574 Views

To find the starting position for consecutive values given the length of consecutive values in an R vector, we can follow the below steps −First of all, create a vector with duplicated values.Find the run length.Create a vector with FALSE of vector size.Find the starting position by setting running length of consecutive values to TRUE for given length.Create the vectorLet’s create a vector having many duplciates so that we can get same consecutive values − Live Demox

How to find the unique elements in multiple vectors in R?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:36:40

751 Views

To find the unique elements in multiple vectors, we can follow the below steps −First of all, create a number of vectors.Use setdiff function to find the common elements in all the vectors.Create the vectorsLet’s create a number of vectors as shown below − Live Demox

How to find the common elements in multiple vectors in R?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:35:30

675 Views

To find the common elements in multiple vectors, we can follow the below steps −First of all, create a number of vectors.Use intersect function to find the common elements in all the vectors.Create the vectorsLet’s create a number of vectors as shown below − Live Demox

How to add a column to data.table object in R?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:34:04

5K+ Views

To add a column to data.table object, we can follow the below steps −First of all, create a data.table object.Add a column to the object using := functionCreate the data.table objectLet’s create a data.table object as shown below −library(data.table) x

How to check if a column is categorical in R data frame?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:32:55

4K+ Views

To check if a column is categorical in R data frame, we can follow the below steps −First of all, create a data frame.Use class function to check the class of the column.Create the data frameLet's create a data frame as shown below − Live Demox

How to set the number of digits to be printed for summary command without using options(digits) in R?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:31:24

87 Views

To set the nuber of digits to be printed for summary command without using options(digits), we can use digits argument while printing the summary. −Example 1Using mtcars data and finding the summary statistics with number of digits set to 2 − Live Demosummary(mtcars, digits=2)On executing, the above script generates the below output(this output will vary on your system due to randomization) −Output   mpg             cyl            disp            hp          drat Min.   :10    Min.   :4.0    Min.   : 71    Min. ... Read More

How to find the number of rows in a data.table where two or more column values meet a criteria in R?

Nizamuddin Siddiqui
Updated on 13-Aug-2021 15:30:33

256 Views

To find the number of rows in a data.table where two or more column values meet a criteria, we can follow the below steps −First of all, create a data.table object.Find the number of rows meeting a criteria.Create data.table objectLet’s create a data.table object as shown below −x

Advertisements