i

R Programming Complete Tutorial

Correlation

Generally, correlation is characterized as a linear relationship measure between two quantitative variables. In a positive correlation, if one variable increases, the values of the other will also increase. When the values of one variable decrease as the values to another rise to form an inverse relationship, this is known as a negative correlation.Where it is possible to predict the values of one variable based on the other, the relationship between the two variables is defined as a strong correlation, with a reasonably high level of accuracy. A weak correlation is one where one variable's values are related to the other on average, but there are many exceptions.

We can visualize the relationship using the scatter plot.

  • cor(mtcars$mpg,mtcars$disp): -0.8475514

  • cor(mtcars$wt,mtcars$hp):  0.6587479