데이터출처 https://www.kaggle.com/lava18/google-play-store-apps 데이터는 kaggle 사이트에서 가져왔다. 가장 먼저 패키지를 다운로드하여 라이브러리에 부착시킨다. 데이터셋을 가져와 데이터 전처리과정을 거친다. Size 의 ’M’값 제거 -> gsub(), ’Varies with device’값을 NA 로 교체, Rating의 ’NaN’값을 Na 로 교체 한 후 na.omit() Reviews 숫자형으로 변환, Installs의 + 제거, ’Current Ver’의 ’Varies with device’값을 NA 로 교체하기
library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
library(packcircles)
library(viridis)
## Loading required package: viridisLite
google <- read_excel("googleplaystore1.xlsx")
head(google)
## # A tibble: 6 x 13
## App Category Rating Reviews Size Installs Type Price `Content Rating`
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 Phot~ ART_AND~ 4.099~ 159 19M 10,000+ Free 0 Everyone
## 2 Colo~ ART_AND~ 3.9 967 14M 500,000+ Free 0 Everyone
## 3 U La~ ART_AND~ 4.7 87510 8.7M 5,000,0~ Free 0 Everyone
## 4 Sket~ ART_AND~ 4.5 215644 25M 50,000,~ Free 0 Teen
## 5 Pixe~ ART_AND~ 4.3 967 2.8M 100,000+ Free 0 Everyone
## 6 Pape~ ART_AND~ 4.400~ 167 5.6M 50,000+ Free 0 Everyone
## # ... with 4 more variables: Genres <chr>, `Last Updated` <chr>, `Current
## # Ver` <chr>, `Android Ver` <chr>
cp_google <- google
cp_google$Size <- ifelse(cp_google$Size == 'Varies with device', NA , cp_google$Size)
cp_google$Rating <- ifelse(cp_google$Rating == 'NaN', NA , cp_google$Rating)
cp_google <- na.omit(cp_google)
cp_google$Reviews <- as.numeric(cp_google$Reviews)
cp_google$Size <- gsub("M","",cp_google$Size)
cp_google$Installs <- ifelse( cp_google$Installs == '1+', 1,
ifelse(cp_google$Installs == '10+', 10 ,
ifelse(cp_google$Installs == '100+',100,
ifelse(cp_google$Installs == '1,000+',1000,
ifelse(cp_google$Installs == '10,000+',10000,
ifelse(cp_google$Installs=='100,000+',100000,
ifelse(cp_google$Installs=='5+',5,
ifelse(cp_google$Installs=='50+',50,
ifelse(cp_google$Installs=='500+',500,
ifelse(cp_google$Installs =='5,000+',5000,
ifelse(cp_google$Installs=='50,000+',50000,
ifelse(cp_google$Installs=='1,000,000+',1000000,
ifelse(cp_google$Installs=='500,000+',500000,
ifelse(cp_google$Installs=='5,000,000+',5000000,
ifelse(cp_google$Installs=='10,000,000+',10000000,
ifelse(cp_google$Installs=='50,000,000+',50000000, ifelse(google$Installs=='100,000,000+',100000000, ifelse(google$Installs=='500,000,000+',500000000, ifelse(google$Installs=='1,000,000,000+',1000000000,NA)))))))))))))))))))
cp_google$`Current Ver` <- ifelse(cp_google$`Current Ver` == 'Varies with device', NA , cp_google$`Current Ver`)
cp_google$`Current Ver` <- ifelse(cp_google$`Current Ver` == 'NaN', NA , cp_google$`Current Ver`)
cp_google <- na.omit(cp_google)
is.numeric(cp_google$Size)
## [1] FALSE
cp_google$Size <-as.numeric(cp_google$Size)
## Warning: 강제형변환에 의해 생성된 NA 입니다
head(cp_google)
## # A tibble: 6 x 13
## App Category Rating Reviews Size Installs Type Price `Content Rating`
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> <chr> <chr>
## 1 Phot~ ART_AND~ 4.099~ 159 19 10000 Free 0 Everyone
## 2 Colo~ ART_AND~ 3.9 967 14 500000 Free 0 Everyone
## 3 U La~ ART_AND~ 4.7 87510 8.7 5000000 Free 0 Everyone
## 4 Pixe~ ART_AND~ 4.3 967 2.8 100000 Free 0 Everyone
## 5 Pape~ ART_AND~ 4.400~ 167 5.6 50000 Free 0 Everyone
## 6 Smok~ ART_AND~ 3.8 178 19 50000 Free 0 Everyone
## # ... with 4 more variables: Genres <chr>, `Last Updated` <chr>, `Current
## # Ver` <chr>, `Android Ver` <chr>
데이터셋에 어떤 카테고리가 있는지 확인 데이터 중에는 가족, 게임 등이 많다는 것을 확인할 수 있다.
# 장르별 빈도수 데이터 생성
category <- cp_google %>%
filter(!is.na(Category)) %>%
group_by(Category) %>%
summarise(n = n()) %>%
arrange(desc(n))
# 1. 그래프 데이터 만들기
data <- data.frame(group=category$Category, value=category$n)
# 2. 레이아웃을 생성하고, sizetype은 값에 비례할 항목에 대한 선호도에 따라 면적 또는 반지름이 된다.
packing <- circleProgressiveLayout(data$value, sizetype='area')
data <- cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
# 3. 색상 지정하고 그래프 보여주기
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
scale_fill_manual(values = magma(nrow(data))) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
가정 : 다운로드 수가 많으면 리뷰 수도 많을까?
결론 : 다운로드와 리뷰는 밀접한 관계다
# 장르별 평균 다운로드 수 데이터 생성
Category_install <- cp_google %>%
filter(!is.na(Installs) & !is.na(Category) & !is.na(Type)) %>%
group_by(Category, Type) %>%
summarise(mean_install = mean(Installs)) %>%
arrange(desc(mean_install))
# 평균 다운로드 수 그래프 생성
result <- ggplot(data = Category_install, aes( x = reorder(Category_install$Category,-Category_install$mean_install) , y=Category_install$mean_install)) + geom_col() + coord_flip()
result + labs(x="장르",y="다운로드",title = "장르별 다운로드 수")
# 장르별 평균 리뷰 수 데이터 생성
Category_review <- cp_google %>%
filter(!is.na(Category) & !is.na(Type) & !is.na(Reviews)) %>%
group_by(Category , Type) %>%
summarise(mean_review = mean(Reviews)) %>%
arrange(desc(mean_review))
# 평균 리뷰 수 그래프 생성
result1 <- ggplot(data = Category_review, aes( x = reorder(Category_review$Category,-Category_review$mean_review) , y=Category_review$mean_review)) + geom_col() + coord_flip()
result1 + labs(x="장르",y="리뷰 수",title = "장르별 리뷰뷰 수")
가정 : 유료 어플과 무료 어플의 다운로드 수는 비슷할까?
파랑색이 무료 어플, 빨강색이 유료 어플로 표현되었다.
결론 : 무료인 어플이 훨씬 많다.
# 데이터는 Category_install 사용
mycolor <- ifelse(Category_install$Type == 'Paid', "type1", "type2")
# 그래프 생성
ggplot(data = Category_install, aes(x=Category_install$Type, y=Category_install$mean_install)) +
geom_segment( aes(x=Category_install$Category, xend=Category_install$Category, y=1, yend=Category_install$mean_install, color=mycolor), size=1, alpha=0.9) +
theme_light() +
theme(
axis.text.x = element_text(angle = 90),
legend.position = "none",
panel.border = element_blank(),
) +
xlab("") +
ylab("Value of Y")
가정 : 다운로드와 사이즈는 연관되어 있을까?
결론 : 다운로드와 사이즈는 연관되어 있지 않다.
Sports < Familly < Game 순으로 크다.
# 장르별 평균 다운로드 수와 평균 사이즈 데이터 설정
Category_install_size <- cp_google %>%
filter(!is.na(Size) & !is.na(Category) & !is.na(Installs)) %>%
group_by(Category) %>%
summarise(mean_install = mean(Installs) , mean_size = mean(Size)) %>%
arrange(desc(mean_size))
# 그래프
result3 <- ggplot(data=Category_install_size, aes( x = reorder(Category_install_size$Category,Category_install_size$mean_install) , y= Category_install_size$mean_size)) + geom_col( ) + coord_flip()
result3 + labs(x="Genre",y="Size And Install",title = "Size by genre")