Last active
February 8, 2019 07:51
-
-
Save toyeiei/c01249cce4e6d15bfd8f250fd63b7712 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dplyr package | |
install.packages("dplyr") | |
library(dplyr) | |
# review page structure | |
glimpse(page) | |
# select these four columns for our analysis | |
small_page <- page %>% select(type, like=likes_count, comment=comments_count, share=shares_count) | |
small_page$type <- as.factor(small_page$type) | |
# do some deeper analysis | |
# 1. compute the ratio of share per like | |
small_page %>% | |
mutate(like = like + 1, share = share + 1) %>% | |
mutate(ratio_share_like = share / like) %>% | |
summarise(avg_ratio = mean(ratio_share_like), | |
median_ratio = median(ratio_share_like), | |
max_ratio = max(ratio_share_like), | |
min_ratio = min(ratio_share_like)) | |
# 2. what kind of content get most likes | |
small_page %>% | |
group_by(type) %>% | |
summarise(avg_like = mean(like)) %>% | |
arrange(desc(avg_like)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment