
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 2038 Articles for R Programming

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

755 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

702 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

332 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

875 Views
When we create boxplots for multiple categories in R using boxplot function, by default the X-axis labels are represented by numbers. But we might want to express the categories by their name. In this situation, we can use names argument along with the boxplot function.Consider the below vectors that represent different categories and create the boxplot for these categories −ExampleClass1
How to change the color of bars in histogram for values that are greater than 0 or less than 0 in R?

292 Views
Although, the histogram represents the distribution of a complete set of values but we might want to visualize that histogram based on the division of some threshold value. For example, we might want to visualize the histogram with different bars that have values greater than 1 or less than 1. This will help us to understand the distribution of the values in whole data set that lies above or below certain value. For this purpose, we can simply use hist function with col argument to change the color of the values that are greater than or less than a fixed ... Read More

6K+ Views
The residual variance is the variance of the values that are calculated by finding the distance between regression line and the actual points, this distance is actually called the residual. Suppose we have a linear regression model named as Model then finding the residual variance can be done as (summary(Model)$sigma)**2.Examplex1

1K+ Views
In general, the scatterplot is used to visualize the relationship between two columns of an R data frame but if we want to display the two columns separately not as a pair then we need to use matplot function. This function will create a plot for all the values in the two columns and represent them by their column number.Consider the below data frame −Example Live Demoset.seed(222) x