Last active
December 13, 2020 09:41
-
-
Save audhiaprilliant/916d624f8b19aebccd51ccbcf67a4a76 to your computer and use it in GitHub Desktop.
Twitter Data Visualization using ggplot2
This file contains hidden or 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
| # Total tweets of 2019-05-28 | |
| ggplot(data.hour.date1)+ | |
| geom_bar(aes(x = Hour, | |
| y = Total.Tweets, | |
| fill = I('red')), | |
| stat = 'identity', | |
| alpha = 0.75, | |
| show.legend = FALSE)+ | |
| geom_hline(yintercept = mean(data.hour.date1$Total.Tweets), | |
| col = I('black'), | |
| size = 1)+ | |
| geom_text(aes(fontface = 'italic', | |
| label = paste('Average:', | |
| ceiling(mean(data.hour.date1$Total.Tweets)), | |
| 'Tweets per hour'), | |
| x = 6.5, | |
| y = mean(data.hour.date1$Total.Tweets)+5), | |
| hjust = 'left', | |
| size = 4)+ | |
| labs(title = 'Total Tweets per Hours - Prabowo Subianto', | |
| subtitle = '28 May 2019', | |
| caption = 'Twitter Crawling 28 - 29 May 2019')+ | |
| xlab('Time of Day')+ | |
| ylab('Total Tweets')+ | |
| ylim(c(0,100))+ | |
| theme_bw()+ | |
| scale_fill_brewer(palette = 'Dark2') | |
| # Total tweets of 2019-05-29 | |
| ggplot(data.hour.date2)+ | |
| geom_bar(aes(x = Hour, | |
| y = Total.Tweets, | |
| fill = I('red')), | |
| stat = 'identity', | |
| alpha = 0.75, | |
| show.legend = FALSE)+ | |
| geom_hline(yintercept = mean(data.hour.date2$Total.Tweets), | |
| col = I('black'), | |
| size = 1)+ | |
| geom_text(aes(fontface = 'italic', | |
| label = paste('Average:', | |
| ceiling(mean(data.hour.date2$Total.Tweets)), | |
| 'Tweets per hour'), | |
| x = 1, | |
| y = mean(data.hour.date2$Total.Tweets)+6), | |
| hjust = 'left', | |
| size = 4)+ | |
| labs(title = 'Total Tweets per Hours - Prabowo Subianto', | |
| subtitle = '29 May 2019', | |
| caption = 'Twitter Crawling 28 - 29 May 2019')+ | |
| xlab('Time of Day')+ | |
| ylab('Total Tweets')+ | |
| ylim(c(0,100))+ | |
| theme_bw()+ | |
| scale_fill_brewer(palette = 'Dark2') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment