Below is the code for calculating the correlation between energy vs population.
cor(spotify$energy, spotify$popularity)
## [1] 0.001056136
Below is the code for calculating the linear regression model for energy vs population.
model <- lm(popularity ~ energy, data = spotify)
summary(model)
##
## Call:
## lm(formula = popularity ~ energy, data = spotify)
##
## Residuals:
## Min 1Q Median 3Q Max
## -33.272 -16.248 1.728 16.763 66.777
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 33.17847 0.18095 183.362 <2e-16 ***
## energy 0.09366 0.26264 0.357 0.721
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 22.31 on 113998 degrees of freedom
## Multiple R-squared: 1.115e-06, Adjusted R-squared: -7.657e-06
## F-statistic: 0.1272 on 1 and 113998 DF, p-value: 0.7214