Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 919 of 3366
759 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
9K+ 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
402 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
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
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
318 Views
We are given with a string ‘str’ of any given length. The task is to rearrange the characters in such a manner that there will be maximum substrings that 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 the string to maximize the number of palindromic substrings is: iinnt.Explanation − We are given a string ... Read More
386 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
723 Views
To create a new column with ratio of two columns based on a condition in an R data frame, we can use division sign with ifelse function.For example, if we have a data frame called df that contains two columns say X and Y and we want to create a new column with ratio of X and Y based on a condition that X is greater than 5 then we can use the below given command −df$Ratio_X_Y5,X/Y,NA))Example 1Following snippet creates a sample data frame −x1
559 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
How to display X-axis tick marks as minimum and maximum only without their values using plotly in R?
500 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