library(readxl)
library(tidyverse)
my_data <- read_excel("advertising_randomized.xlsx")
head(my_data)
## # A tibble: 6 × 6
## X X1 TV radio newspaper sales
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 37 115 170. 24.4 45.0 16.2
## 2 60 54 106. 16.5 4.22 14.3
## 3 54 278 152. 40.7 30.7 17.6
## 4 68 28 119. 5.78 56.6 9.49
## 5 215 71 110. 18.3 29.6 15.8
## 6 177 151 54.7 1.89 79.0 5.62
glimpse(my_data)
## Rows: 66
## Columns: 6
## $ X <dbl> 37, 60, 54, 68, 215, 177, 105, 36, 192, 97, 84, 117, 63, 67,…
## $ X1 <dbl> 115, 54, 278, 28, 71, 151, 140, 29, 155, 77, 42, 91, 2, 234,…
## $ TV <dbl> 169.50, 106.10, 151.51, 119.25, 110.37, 54.73, 108.01, 260.0…
## $ radio <dbl> 24.38, 16.47, 40.66, 5.78, 18.27, 1.89, 31.30, 17.47, 23.15,…
## $ newspaper <dbl> 44.97, 4.22, 30.67, 56.57, 29.61, 78.96, 45.41, 33.60, 31.69…
## $ sales <dbl> 16.21, 14.34, 17.65, 9.49, 15.81, 5.62, 18.44, 12.67, 15.65,…
ggplot(my_data, aes(x = TV, y = sales)) +
geom_point() +
geom_smooth(method = "lm") +
labs(
title = "Sales vs. TV Advertising",
x = "TV Advertising Budget",
y = "Sales"
)
TV and Sales: The scatterplot shows a negative relationship between TV advertising and Sales. As TV advertising increases, Sales also appear to decrease.
ggplot(my_data, aes(x = radio, y = sales)) +
geom_point() +
geom_smooth(method = "lm") +
labs(
title = "Sales vs. Radio Advertising",
x = "Radio Advertising Budget",
y = "Sales"
)
Radio and Sales: The scatterplot shows a positive relationship between Radio advertising and Sales. The relationship appears somewhat strong, although the points may be more spread out than TV.
ggplot(my_data, aes(x = newspaper, y = sales)) +
geom_point() +
geom_smooth(method = "lm")+
labs(
title = "Sales vs. Newspaper Advertising",
x = "Newspaper Advertising Budget",
y = "Sales"
)
Newspaper and Sales: The scatterplot shows a weaker relationship between Newspaper advertising and Sales. The points may appear more scattered, meaning Newspaper spending may not predict Sales as clearly
ggplot(my_data, aes(x = radio, y = sales, color = cut(newspaper, breaks=3))) +
geom_point()
Looking at the three advertising channels, TV actually has a weak negative relationship with Sales, so spending more on TV doesn’t really lead to more sales in this data. Radio has the strongest positive relationship — as radio spending goes up, sales tend to go up too, which you can see from the upward trend line. Newspaper is pretty much the weakest of the three since the trend line is basically flat and the data points are all over the place.
Out of all three, Radio has the strongest connection to Sales. The scatterplot for Radio shows a pretty clear upward trend, which means that when companies spend more on radio ads, sales tend to be higher. Newspaper, on the other hand, is the weakest predictor — the points are scattered everywhere and the trend line is almost completely flat, so there’s not much of a pattern there.