Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

How to delete a row from an R data frame if any value in the row is greater than n?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 6K+ Views

To delete a row from an R data frame if any value in the row is greater than n can be done by using the subsetting with single square brackets and negation operator. We will subset the values that are greater than n and then take the negation of the subset as shown in the below given examples.Example 1Following snippet creates a sample data frame −x1

Read More

How to find the sum product of two matrix by row in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 853 Views

To find the sum product of two matrix by row in R, we can use rowSums function by passing the multiplication of the matrices.For example, if we have two matrices say Matrix1 and Matrix2 then, the sum product of these two matrices by row can be found by using the following command −rowSums(Matrix1*Matrix2)Example 1Following snippet creates a matrix −M1

Read More

Rearrange the given source code in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 02-Nov-2021 491 Views

We are given a string type variable, let's say, str which will be used to store the source code then calculate the size of the string and pass it to the function. The task is to rearrange the given source code and then print the result.Let us see various input output scenarios for this −Input − string str ="#include using namespace std; int main()"    "{ int sum, first, second; sum = first + second; printf("%d", c);"    " return 0;}"Output −#include using namespace std; int main(){    int sum, first, second;    sum = first + second;    printf("%d", ...

Read More

How to multiply each value in a column by a constant in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 10K+ Views

To multiply each value in a column by a constant, we can use multiplication sign *.For example, if we have a data frame called df that contains a column say x. Now, if we want to multiply each value in x with 10 then we can use the below mentioned command −df$x

Read More

How to deal with error invalid xlim value in base R plot?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 4K+ Views

The error invalid xlim value occurs when we incorrectly provide the xlim values, these values are not used in sequence, we just need to provide first and the last value. For Example, if we want to create a point chart of 1 to 5 with xlim having values between -5 to 15 then we can use the command as follows −plot(1:5, xlim=c(-5:15))ExampleAdd the following code to the above command −plot(1:10) OutputIf you execute the above given command, it generates the following Output −Add the following code to the above snippet −plot(1:10) plot(1:10, xlim=c(-15:15)) Error in plot.window(...) : invalid 'xlim' value ...

Read More

Extract string vector elements up to a fixed number of characters in R.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 638 Views

To extract string vector elements up to a fixed number of characters in R, we can use substring function of base R.For Example, if we have a vector of strings say X that contains 100 string values and we want to find the first five character of each value then we can use the command as given below −substring(X,1,5)Example 1Following snippet creates a sample data frame −x1

Read More

How to create histogram for discrete column in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 3K+ Views

To create histogram for discrete column in an R data frame, we can use geom_bar function of ggplot2 package and set the width to 1 also passing same column for x and y in aes.For example, if we have a data frame called df that contains a discrete column say x then the histogram for data in x can be created by using the below given command −ggplot(df,aes(x,x))+geom_bar(stat="identity",width=1)ExampleFollowing snippet creates a sample data frame −x

Read More

Rearrangement of a number which is also divisible by it in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 02-Nov-2021 490 Views

We are given an integer type number, let's say, number. The task is to rearrange number digit’s in such a manner that a number formed after rearrangement is also divisible by the given number i.e. ’number’.Let us see various input output scenarios for this −Input − int number = 100035Output − Rearrangement of a number which is also divisible by it is: 300105Explanation − we are given an integer number as ‘number’ i.e. 100035. Now, the task is to rearrange these given digits in such a manner that the formed number will be divisible by 100035. So, after rearranging the digits we got ...

Read More

Rearrange characters to form palindrome if possible in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 02-Nov-2021 1K+ Views

We are given with a string ‘str’ of any given length. The task is to rearrange the characters in such a manner that the output will be a palindrome string without adding or removing a character from the given input string. Palindrome string is the one in which the characters are arranged in such a manner that they pronounce the same from start and last.Let us see various input output scenarios for this −Input − string str = "itnin"Output − Rearrangement of characters to form palindrome if possible is: nitinExplanation − We are given a string type variable let’s say, str. Now we ...

Read More

How to display X-axis tick marks as minimum and maximum only without their values using plotly in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 598 Views

To display X-axis tick marks as minimum and maximum only without their values using plotly, we can use layout function of plot_ly package where we can pass the values for minimum and maximum using xaxis argument and the text using ticktext argument as shown in the below example.ExampleFollowing snippet creates a sample data frame −x

Read More
Showing 47741–47750 of 61,298 articles
Advertisements