library(gtrendsR)
## Warning: package 'gtrendsR' was built under R version 4.5.3
library(ggplot2)
library(tidyr)
library(readr)
data_hp <- read_csv("C:/Users/HP/Downloads/data time series HP.csv")
## Rows: 52 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (3): Samsung, iPhone, Xiaomi
## date (1): Time
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
rata_rata <- data.frame(
Brand = c("Samsung", "iPhone", "Xiaomi"),
Mean = c(
mean(data_hp$Samsung),
mean(data_hp$iPhone),
mean(data_hp$Xiaomi)
)
)
rata_rata
## Brand Mean
## 1 Samsung 55.07692
## 2 iPhone 58.86538
## 3 Xiaomi 12.11538
Berikut merupakan grafik rata-rata popularitas smartphone.
ggplot(rata_rata,
aes(x = Brand,
y = Mean,
fill = Brand)) +
geom_bar(stat = "identity") +
labs(title = "Rata-rata Popularitas Smartphone",
x = "Brand",
y = "Rata-rata Skor") +
theme_minimal()
Berdasarkan visualisasi di atas, dapat diketahui brand smartphone yang memiliki popularitas tertinggi adalah iPhone