Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

How to subset a named vector based on names in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 939 Views

To subset a named vector based on names, we can follow the below steps −Create a named vector.Subset the vector using grepl.Create the named vectorLet’s create a name vector as shown below −V

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 310 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 −summary(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 check if a column is categorical in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 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 −x

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 996 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 −x

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ 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 −x

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 871 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 −x

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 246 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 −x

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ 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 −Group

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 543 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 −x

Read More

How to find the summary by categorical variable in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

To find the summary by categorical variable, we can follow the below steps −Use inbuilt data sets or create a new data set.Find the summary statistics with by function.Use inbuilt data setLet’s consider mtcars data set in base R −data(mtcars) head(mtcars, 25)On executing, the above script generates the below output(this output will vary on your system due to randomization) −                      mpg  cyl disp   hp  drat   wt   qsec vs am gear carb Mazda RX4             21.0 6   160.0 110  3.90 2.620 16.46 ...

Read More
Showing 24941–24950 of 61,297 articles
Advertisements