
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

538 Views
By default, the positive signs are not displayed in any plot in R. It is well known that if there is no sign seen with any value then it is considered positive, therefore, we do not need the sign but to distinguish between 0 and positive values it could be done. To display positive sign for X-axis labels, we can use scale_x_continuous function.Consider the below data frame −Example Live Demox

10K+ Views
To change the size of plots arranged using grid.arrange, we can use heights argument. The heights argument will have a vector equal to the number of plots that we want to arrange inside grid.arrange. The size of the plots will vary depending on the values in this vector.Consider the below data frame −Example Live Demox

3K+ Views
To create a cumulative sum plot in base R, we can simply use plot function. For cumulative sums inside the plot, the cumsum function needs to be used for the variable that has to be summed up with cumulation. For example, if we have two vectors say x and y then the plot with cumulative sum plot can be created as plot(x,cumsum(y)).Examplex1

2K+ Views
To create a plot in base R with tick marks of larger size, we can make use of axis function tck argument. The tck argument value will decide the size of the tick mark but since the ticks lie below the plot area hence the value will have a negative associated with it. Therefore, it will be like -0.05. Check out the below examples to understand how it works.Exampleplot(1:10,axes=FALSE,frame=TRUE) axis(1,1:10,tck=-0.02) axis(2,1:10,tck=-0.02)OutputExampleplot(1:10,axes=FALSE,frame=TRUE) axis(1,1:10,tck=-0.05) axis(2,1:10,tck=-0.05)Output

8K+ Views
To change the linetype for geom_vline, we can use linetype argument in geom_vline function of ggplot2 package. There are mainly six linetypes that can be used and these values are 0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash.Consider the below data frame −x

161 Views
If we have a string vector then all the values in the vector are not likely to be of same size and we might be looking for smaller size or bigger size values. Therefore, if we want to extract all string values from a vector in R with maximum lengths even if there are duplicates can be done by using the max and nchar function as shown in the below examples.Example Live Demox1

892 Views
To find the groupwise number of positive and negative values in an R data frame, we can use mutate function of dplyr package. For example, if we have a data frame called df with one categorical column x and one numerical column y then the number of positive and negative values for categorical column can be found by using the below command −df%>%group_by(x)%>%mutate(positive=sum(y>0),negative=sum(y

948 Views
To create a linear model with interaction term only, we can use the interaction variable while creating the model. For example, if we have a data frame called df that has two independent variables say V1 and V2 and one dependent variable Y then the linear model with interaction term only can be created as lm(Y~V1:V2,data=df).Consider the below data frame −Example Live Demox1

258 Views
To create a perpendicular arrow in base R plot, we can use arrows function. There are five arguments of arrows function that will be used to create the perpendicular arrow. The first four values define the position of the arrow and the last argument xpd allows R to create the arrow. Check out the below examples to understand how it works.Exampleplot(1:10) arrows(1,-1,1,0,xpd=TRUE)OutputExampleplot(1:10) arrows(1,-1,1,2,xpd=TRUE)OutputExampleplot(1:10) arrows(2,-1,2,2,xpd=TRUE)Output