-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
56 lines (39 loc) · 1.12 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
title: "How many packages are there on CRAN?"
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
This shows one how to scrape data directly from a website
<!-- `r emo::ji("spider_web")` -->
(an html table of CRAN packages, structure it as a dataframe and plot it).
> Loads R packages `r emo::ji("package")`
```{r setup,message=F}
library(tidyverse)
library(ggthemes)
```
> Loads functionality to decode and plot CRAN data `r emo::ji("computer")`
```{r}
source("count_cran.R")
```
> Reads package table (as html) from CRAN and decode it into a dataframe: `r emo::ji("man_technologist")`
```{r,cache=T}
url_cran <- "http://cran.r-project.org/web/packages/available_packages_by_date.html"
df_cran_pre <- read_file(url_cran)
df_cran <- df_cran_pre %>% cran_html_to_df
nrow(df_cran)
```
What's in it?
```{r}
glimpse(df_cran)
```
> What are the top 10 words used in package titles?
```{r}
df_cran %>%
get_top_words(10) %>%
plot_top_words
```
> Plots it! `r emo::ji("chart")`
```{r}
df_cran %>% plot_cran_df
```
> There you have it! R is growing exponentially!`r emo::ji("smile")`