
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

406 Views
To create a time series plot in R without time vector, we can use ts.plot function.For Example, if we have a vector called X then we can create the time series plot of X by using the command ts.plot(X), the Output of this command will have a time axis in place of X-axis. Check out the below Examples to understand how it works.Example 1Consider the following vector −x

3K+ Views
To create a plot of matrix elements with the help of corrplot function, we would need to set is.corr argument to FALSE so that the matrix values will be plotted in the diagram, otherwise, the corrplot function requires correlation matrix instead of a matrix hence there will be an error as shown in the Example below.ExampleConsider the matrix given below −M

696 Views
To draw concentric circles, we can use draw.circle function of plotrix package but firstly, we would need to create a blank graph with plot function as shown below.For Example, we can create three concentric circles at position X=5 and Y=5 having radius of 1, 2, and 3 by using the below command −draw.circle(5, 5, c(3, 2, 1), col=c("blue", "red", "green"))ExampleTo create three concentric circles at position X=5 and Y=5 having radius of 1, 2, and 3 add the following code to the above snippet −plot(1:10, type="n")OutputIf you execute all the above given snippets as a single program, it generates the ... Read More

519 Views
To create vertical line in xyplot, we can use abline 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 scatterplot between X and Y using xyplot with a vertical line at X = 2 then we can use the below command −xyplot(y~x,df,abline=c(v=2))ExampleConsider the data frame given below −x

931 Views
To combine values of two columns separated with hyphen in an R data frame, we can use apply function.For Example, if we have a data frame called df that contains only two columns say X and Y then we can combine the values in X and Y by using the below command given below −df$X_Y

6K+ Views
To find the class of columns of an R data frame, we can use class function along with sapply and as.data.frame function.For Example, if we have a data frame called DF then we can find the class of columns in DF by using the command as follows −data.frame(sapply(DF, class))Example 1Consider the below data frame −head(mtcars, 20) The following dataframe is created mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 21.0 6 160.0 110 3.90 ... Read More

1K+ Views
A list in R can have large number of elements and also of different types. If we have a list that contain vectors and we want to check which list element contains a particular value then we can use which function along with sapply function.For Example, if we have a list called LIST then we can find which element of LIST contains 5 then we can use the command given below −which(sapply(LIST, FUN=function(X) 5 %in% X))Example 1Consider the List given below −List1

2K+ Views
To convert strings in R data frame to unique integers, we first need to extract the unique strings in the data frame and then read them inside data.frame function with as.numeric along with factor function.Check out the below Examples to understand how it works.Example 1Consider the below data frame −x1

3K+ Views
If we have a vector of dates that contains all days in a week then we can use that vector to create a date column by excluding weekends with the help of subsetting the vector as shown in the below Examples. After subsetting the vector, we will just need to pass the vector in data.frame function.Example 1Consider the below vector of dates −x

791 Views
The default boxplot in R has straight border line type that display end point(s) excluding outliers. To change these border lines from a boxplot, we can use staplelty argument.For Example, if we have a vector called X then we can create the boxplot of X with different border line type by using the command boxplot(X,staplelty=15). The argument can take different values. Check out the below Examples to understand how it works.ExampleConsider the below vector −x