Programming Articles

Page 1271 of 2547

How to write a long line for the X-label of a scatterplot in R using ggplot2?

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

When we create a plot in R, the variable names are automatically plotted as axes labels but sometimes we want to give a brief detail of the X-label or a Y-label. If that brief is not small so that the expression function can contain the length of the label then it becomes difficult but it can be done with the help of atop inside expression.ExampleConsider the below data frame −set.seed(123) x

Read More

Count pairs with Odd XOR in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 269 Views

We are given an integer array and the task is to count the total number of pairs that can be formed using the given array values such that the XOR operation on the pairs will result in an ODD value.The truth table for XOR operation is given belowABA XOR B000101011110Input − int arr[] = {2, 8, 1, 5, 11}Output − Count of pairs with Odd XOR are − 6Explanation −a1a2a1 XOR a228102132572119819851381131541111051114Approach used in the below program is as followsInput an array of integer elements to form an pairCalculate the size of an array pass the data to the function ...

Read More

Count Odd and Even numbers in a range from L to R in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 521 Views

We are given a range starting from L to R of integer values and the task is to calculate the count of odd numbers and the even numbers in the range.Input − L = 7, R = 17Output − Count of Even numbers in a range from L to R are − 5Count of Odd numbers in a range from L to R are − 6Input − L = 1, R = 10Output − Count of Even numbers in a range from L to R are − 5Count of Odd numbers in a range from L to R are − ...

Read More

Count of pairs (x, y) in an array such that x < y in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 365 Views

We are given an integer array and the task is to count the total number of pairs (x, y) that can be formed using the given array values such that the integer value of x is less than y.Input − int arr[] = { 2, 4, 3, 1 }Output − Count of pairs (x, y) in an array such that x < y are − 6Explanation −XYX < Y24true23true21false43false41false42false32false12true34true14true31false13falseApproach used in the below program is as followsInput an array of integer elements to form an pairCalculate the size of an array pass the data to the function for further processingCreate ...

Read More

How to remove NULL values from a list in R?

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

The value NULL is used to represent an object especially a list of length zero. If a list contains NULL then we might want to replace it with another value or remove it from the list if we do not have any replacement for it. To remove the NULL value from a list, we can use the negation of sapply with is.NULL.Examplesx

Read More

Count of pairs from 1 to a and 1 to b whose sum is divisible by N in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 233 Views

We are given an integer array and the task is to count the total number of pairs (x, y) that can be formed using the given array values such that the integer value of x is less than y.Input − int a = 2, b = 3, n = 2Output − Count of pairs from 1 to a and 1 to b whose sum is divisible by N are − 3Explanation −Firstly, We will start from 1 to a which includes 1, 2 Now, we will start from 1 to b which includes 1, 2, 3 So the pairs that ...

Read More

Count of alphabets having ASCII value less than and greater than k in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 397 Views

We are given a string of any length and the task is to calculate the count of alphabets having ASCII values less than or greater than or equals to the given integer value k.ASCII value for character A-Z are given belowABCDEFGHIJKLMNOPQRS65666768697071727374757677787980818283TUVWXYZ84858687888990ASCII value for characters a-z are given belowabcdefghijklmnopqrs979899100101102103104105106107108109110111112113114114tuvwxyz116117118119120121122Input − str = “TuTorials PoinT”, int k = 100Output −Count of alphabets having ASCII value less than k are − 6Count of alphabets having ASCII value equals or greater than k are − 9Explanation −We are given with k as 100 so we will check ASCII values of the characters in the ...

Read More

How to find the maximum using aggregate and get the output with all the columns in R?

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

When we use aggregate function to find maximum or any other value, the output of the aggregation does not provide all the columns that corresponds to the maximum value. Therefore, we need to merge the data frame obtained by using aggregate with the original data frame. In this way, we will get only those rows that are common between the new data frame and the original one.ExampleConsider the below data frame −set.seed(99) x1

Read More

Count smaller numbers whose XOR with n produces greater value in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 193 Views

We are given an integer number let’s say, num and the task is to count the smaller numbers less than num whose XOR with num will result in a value greater than the XOR value..The truth table for XOR operation is given belowABA XOR B000101011110Input − int num = 11Output − Count of smaller numbers whose XOR with n produces greater value are − 4Explanation −We are given with the num as 11 which means we need to find XOR of num with the numbers less than num. So the numbers are 1 XOR 11 < 11(FALSE), 2 XOR 11 ...

Read More

How to convert two columns of an R data frame to a named vector?

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

If two columns are of a form such that one column contains the name of the vector values and another column having the values of a vector then we might want to convert them into a vector. To do this, we can simply read the vectors with their data type and structure them with structure function.Example 1x1

Read More
Showing 12701–12710 of 25,466 articles
Advertisements