Correlation and Linear Regression in R

Let’s take a look at correlation and linear regression in R.

Correlation in R

Wood density and timber hardness appear to be positively related, and the relationship seems to be fairly linear. We can look at the strength of the association between dens and hardness using correlation. Since the cor() function has no data argument, we need to use the with() function, as shown in the code widget below:

Get hands-on with 1400+ tech skills courses.