Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

How to add a variable description in R?

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

To add a variable description in R, we can use comment function and if we want to have a look at the description then structure call of the data frame will be used. For example, if we have a data frame say df that contains a column x then we can describe x by using the command comment(df$x)

Read More

How to randomly sample rows from an R data frame using sample_n?

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

To randomly sample rows from an R data frame using sample_n, we can directly pass the sample size inside sample_n function of dplyr package. For example, if we have data frame called df then to create a random sample of 5 rows in df can be done by using the command −df%>%sample_n(5)Example1Consider the below data frame −x1

Read More

Deletion in a Binary Tree in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 6K+ Views

In this tutorial, we are going to learn how to delete a node in a binary tree.The nodes in a binary tree don't follow any order like binary search trees. So, how to arrange the nodes after deleting a node in a binary tree?Well, we will replace the deepest node of the tree with the deleting node. And then we will delete the deepest node from the node.Let's see the steps to solve the problem.Initialize the tree with binary node struct.Write a function (preorder, in order, and postorder) to print the nodes of the tree.Write a function to delete the ...

Read More

Deletions of "01" or "10" in binary string to make it free from "01" or "10" in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 337 Views

In this tutorial, we are going to write a program that finds the total number of pairs (01 or 10) to free the binary string from the pairs (01 and 10). Let's see an example.Input − 101010001Output − 4In the above example, we have to delete a total of 4 pairs to free the binary string from the pairs (01 and 10).The resultant string after deleting all the pairs is 0.We have to delete all the 01 and 10 pairs from the binary string. So, the total number of pairs to be deleted is the minimum of count(1) and count(0).Let's ...

Read More

How to check for palindrome in R?

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

A palindrome is a word or any value that is being read in the same way from right to left as in left to right. For example, 12321, 514212415, ABCDEDCBA, etc. To check palindrome in R, we can create a function using stri_reverse function of stringi package as shown in the below examples.Example1library(stringi) palindrome

Read More

How to return the same index for consecutively duplicated values in an R vector?

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

It is obvious that duplicate values in an R vector do not have same indexes but we might want to create the same index for consecutively duplicated values, this will help to recognize the groups of duplicated values. For this purpose, we can use cumsum function along with diff function as shown in the below examples.Example1x1

Read More

How to find unique matrices in a list in R?

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

A list can contain many types of elements such as vectors, matrices, data frames etc. If we have matrices in a list then to find unique matrices in that list, we can simply use unique function. For example, if we have a list called LIST that contains matrices having some duplicate matrices then unique matrices can be extracted by using unique(LIST).Example1list(M1=matrix(1:25, ncol=5), M2=matrix(1:25, ncol=5), M3=matrix(1:25, ncol=5), M4=matrix(rpois(25, 5), ncol=5)) List1Output$M1 [, 1] [, 2] [, 3] [, 4] [, 5] [1, ] 1 6 11 16 21 [2, ] 2 7 12 17 22 [3, ] 3 8 13 18 ...

Read More

Depth of an N-Ary tree in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 1K+ Views

In this tutorial, we are going to learn how to find the depth of the n-ary tree.An n-ary tree is a tree in which each node of the tree has no more than n child nodes.We have to find the depth of the n-ary tree. We will be using the vector to store the children of each node in the tree.Let's see the steps to solve the problem.Initialize the tree with dummy data.Write a recursive function to find the depth of the n-ary tree.Initialize a variable to store the max depth of the tree.Iterate over the children of each node.The ...

Read More

How to find mean and standard deviation from frequency table in R?

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

To find the mean and standard deviation from frequency table, we would need to apply the formula for mean and standard deviation for frequency data. For example, if we have a data frame called df that contains a column x for units and frequency for counts then the mean and standard deviation can be calculated as −Mean = sum(df$x*df$frequency)/sum(df$frequency) SD = sqrt(sum((df$x−Mean)**2*df$frequency)/(sum(df$frequency)−1)) respectively.Example1x

Read More

How to export data frame in R to excel?

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

To export data frame in R to excel can be done with the help of write.xlsx function of xlsx package. We would need to pass the data frame name, the file name and the sheet name in which we want to save the data frame. For example, if we have a data frame called df with file name Excel_df and on sheet1 then the data frame will be saved by using the below command −write.xlsx(df, file="Excel_df.xlsx", sheetName = "Sheet1")Consider the below data frame −Examplex

Read More
Showing 25401–25410 of 61,297 articles
Advertisements