
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
Found 33676 Articles for Programming

109 Views
The plot area in plot window is fixed by default and we can create a lint chart with extended width so that the chart covers the area of the plot from bottom left to upper right. This can be done by using very large width of the line chart with the help of lwd argument.Consider the below vector and create the very wide line chart to cover the plot area −Examplex

584 Views
The anti-diagonal elements in a matrix are the elements that form straight line from right upper side to right bottom side. For example, if we have a matrix as shown below −1 2 3 4 5 6 7 8 9then the diagonal elements would be 1, 5, 9 and the anti-diagonal elements would be 3, 5, 7.To find the sum of these anti-diagonal elements, we can use apply function.Example Live DemoM1

867 Views
It is common the find the correlation coefficient between columns of an R data frame but we might want to find the correlation coefficient between rows of two data frames. This might be needed in situations where we expect that there exists some relationship row of an R data frame with row of another data frame. For example, row of an R data frame showing buying trend of a customer in one year and the same row of the other data frame showing buying trend of the same customer in another year.Consider the below data frame −Example Live Demox1Read More

8K+ Views
The default value for bins is 30 but if we don’t pass that in geom_histogram then the warning message is shown by R in most of the cases. To avoid that, we can simply put bins=30 inside the geom_histogram() function. This will stop showing the warning message.Consider the below data frame −x

3K+ Views
If we want to use a data frame created in R in the future then it is better to save that data frame as txt file because it is obvious that data creation takes time. This can be done by using write.table function. For example, if we have a data frame df then we can save it as txt file by using the code write.table(df,"df.txt",sep="\t",row.names=FALSE)Consider the below data frame −Example Live Demoset.seed(111) x1

758 Views
If we want to create a categorical vector with all unique values representing strings with numbers at the end then paste0 function can help us in the same. For example, if we want to create a vector for ID up to 10 as ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, and ID10 then it can be done as paste0("ID",seq(1:10)).Example Live Demox1

8K+ Views
In the whole world, the first step people teach to impute missing values is replacing them with the relevant mean. That means if we have a column which has some missing values then replace it with the mean of the remaining values. In R, we can do this by replacing the column with missing values using mean of that column and passing na.rm = TRUE argument along with the same.Consider the below data frame −Example Live Demoset.seed(121) x

8K+ Views
Sometimes date variable is recorded in three different columns representing year, month, and day instead of a single column as date. Therefore, we need to combine these three columns and create a single column. This can be done by using paste function and define the values with as.Date.Consider the below data frame −Example Live DemoYear

703 Views
When we create a matrix in R, the row names and column names are not defined but we can define them separately. If we want to take a subset of rows of a matrix then row numbers can be used within single square brackets but if we want to do it with the names then we need to specify those names.Example Live DemoM1

333 Views
The barplot function create the bars of equal width but if we have equal or unequal width values for each bar then we can use width within the barplot function. Thus, the newly generated barplot will have different width of the bars. For example, if we the width are defined for four categories as 0.25 each then each bar will be of equal width and if they vary as 0.30, 0.40, 0.20, 0.45 then the width of the bars will be different based on these widths.Consider the below vector x and the corresponding width vector −x