Articles on Trending Technologies

Technical articles with clear explanations and examples

How to extract unique values in multiple columns in an R data frame using a single line code?

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

To extract unique values in multiple columns in an R data frame, we first need to create a vector of the column values but for that we would need to read the columns in matrix form. After that we can simply unique function for the extraction. To understand how it works check out the below examples.Consider the below data frame −Examplex1

Read More

Find a Number X whose sum with its digits is equal to N in C++

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

In this tutorial, we are going to find a number whose some including with its digits is equal to the given number N.The idea is simple, we are going to check the left and right 100 numbers of the given number. It won't lie out that bound as N ≤ 1000000000 and the sum won't exceed 100.Let's see the steps to solve the problem.Initialize the number.Write a loop that iterates 100 times.Get the n - i and n + i values.Find the sum of the digits and add them.If anyone of them is equal to the N, print them.ExampleLet's see ...

Read More

How to find the sum of values based on key in other column of an R data frame?

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

If we have a column that is key that means we want to use that column as an independent variable and find the statistical values such as sum, mean, standard deviation, range, etc. for the dependent variable. This can be done with the combination of with and tapply function as shown in the below examples.Consider the below data frame −Examplex1

Read More

How to find the length of the largest string in an R data frame column?

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

The length of the largest string can be found with the help of max function combined with nchar function. For this purpose, we first need to access the appropriate column that contains string values. Suppose, we have a data frame called df that contains a string column defined as CHAR then the length of the largest string will be found by using the command max(nchar(df$CHAR)).Consider the below data frame −Examplex

Read More

How to find the first quartile for a data frame column in R?

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

The first quartile is the value that exists at the 25th percentile, that means there are 25% of values in the data that lie below first quartile. When we find the summary of data frame the output returns this value but if we want to extract only the first quartile then quantile function can be used by specifying the percentage using 0.25.Consider the below data frame −Examplex

Read More

How to create a sequence of values between two vectors in R using corresponding elements?

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

If we have two vectors say x and y, x contains 1, 6 and y contains 5,10 then the sequence of values between these two vectors will be 1, 2, 3, 4, 5 and 6, 7, 8, 9, 10. Here the sequence is created by using the corresponding elements in x and y. To do this in R, we can use mapply function as shown in the below examples.Examplex1

Read More

Find a partition point in array in C++

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

In this tutorial, we are going to find the partition point in an array where all the elements left to the partition point are small and all the elements right to the partition point are large.Let's see the steps to solve the problem.Initialize the array.Iterate over the array.Iterate from 0 to I and check each value whether it is smaller than the current value or not.Iterate from I to n and check each value whether it is larger than the current value or not.If the bot the conditions satisfied, then return the value.Print the partition point.ExampleLet's see the code.#include ...

Read More

How to create boxplot using ggplot2 without whiskers in R?

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

To create boxplot using ggplot2 without whiskers, we need to use coef argument inside geom_boxplot function. For example, if we have data frame called df and there exists one categorical variable x and one response variable y then the boxplots for categories without whiskers can be created by using ggplot(df,aes(x,y))+geom_boxplot(coef=0).Consider the below data frame −Examplex

Read More

How to display 0 at Y-axis using ggplot2 in R?

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

To display 0 at Y-axis, we can set the limits for Y-axis using scale_y_continuous function of ggplot2 package. For example, if we have two columns say x and y in an R data frame called df then the scatterplot with displaying 0 at Y-axis can be created by using the below commandggplot(df,aes(x,y))+geom_point()+scale_y_continuous(limits=c(0,”upperlimit”))Consider the below data frame −Examplex

Read More

Find a peak element in a 2D array in C++

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

In this tutorial, we are going to write a program that finds the peak element in a 2D array.An element is called a peak element if all the elements around it are smaller than the element.Let's see the steps to solve the problem.Initialize the 2D array with dummy data.Iterate over the 2D array.First, check the corner elements of the 2D array.Next, write the conditions for the first and last rows of the 2D array.Now, check for the first and last columns of the 2D array.And finally, check the middle elements.In each case, we have to compare the current element with ...

Read More
Showing 25551–25560 of 61,297 articles
Advertisements