2026-10-18

Why this question?

  • There are many tracks that vary in length.
  • Do longer tracks tend to be more popular?

Why does this relationship matter?

  • Understanding what relates to track popularity may help musicians learn more about their audiences.
  • Exploring this relationship can help us understand whether song length is a useful indicator of popularity.

The Data

What is correlation?

Correlation measures how two variables are related.

  • Positive correlation: As one variable increases, the other tends to increase
  • Negative correlation: As one variable increases, the other tends to decrease
  • Little or no correlation: There is no clear linear relationship between the variables.

In this project

I will use correlation to investigate whether track duration is related to Spotify popularity

The Math Behind Correlation

Pearson’s correlation coefficient (r) measures the strength and direction of a linear relationship between two variables.

\[ r = \frac{\operatorname{Cov}(X,Y)}{s_Xs_Y} \]

  • X represents track duration.

  • Y represents track popularity.

  • (X,Y) represents how the two variables vary together.

  • (s_X) and (s_Y) represent the standard deviations of duration and popularity.

How do we interpret (r)?

  • r ranges from (-1) to (+1).

  • Values near (+1) indicate a strong positive linear relationship.

  • Values near (-1) indicate a strong negative linear relationship.

  • Values near (0) indicate little or no linear relationship.

Visual Representation

A scatterplot comparing track duration and popularity.

  • X-axis: Track duration (minutes)
  • Y-axis: Popularity score (0-100)
  • Trend line: Visual representation of correlation

The correlation for tracks under 10 minutes is approximately 0.009.

This value is very close to zero, suggesting that there is little to no linear relationship between track duration and popularity score.

How Long Are Most Tracks?

Observation:

  • Most tracks fall within the range of 3-4 minutes
  • Very short and very long tracks occur less frequently
  • Tracks lasting 10 minutes or longer were excluded from this analysis to reduce the influence of unusually long recordings

Why this matters: Understanding the distribution helps us see what a typical track length looks like in this dataset.

How R Helped

I used R to calculate the Pearson correlation coefficient between track duration and popularity.

The correlation helped measure the direction and strength of the linear relationship without the graph.

x <- songs_under10$duration_min
y <- songs_under10$popularity

r <- cov(x, y) / (sd(x) * sd(y))

r
## [1] 0.009095281

The result comes out to ~0.009.

This value is very close to zero, suggesting almost no linear relationship between track duration and popularity in this dataset.

Can We Predict Popularity From Track Length?

Linear regression models the relationship between track duration and popularity.

The regression equation is:

\[ \hat{y} = b_0 + b_1x \]
  • y = predicted popularity score

  • b_0 = intercept

  • b_1 = slope of the regression line

  • x = track duration in minutes

What does this mean for our data?

The correlation is close to zero, so track duration alone is not a useful linear predictor of popularity in this dataset.

Interactive Graph if Curious!

Conclusion

  • Little to no linear relationship: The correlation between track duration and popularity was approximately (r = 0.009).

  • Length alone isn’t a useful predictor: Longer tracks were not consistently more or less popular in this dataset.

  • Popularity depends on more than duration: Other factors may play a role in how popular a track becomes.

  • A limitation: Tracks longer than 10 minutes were excluded from the main analysis, so the results do not represent every track in the dataset.

Main takeaway: A longer track is not necessarily a more popular track!