forked from rfordatascience/tidytuesday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
moores_law.R
97 lines (82 loc) · 3.83 KB
/
moores_law.R
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
library(tidyverse)
library(rvest)
url <- "https://en.wikipedia.org/wiki/Transistor_count"
tables <- url %>%
read_html() %>%
html_table(fill = TRUE)
df1 <- tables %>% chuck(1) %>%
janitor::clean_names() %>%
as_tibble()
df1_clean <- df1 %>%
mutate(
# transistor_count = gsub("\\[[^\\]]*\\]", "", transistor_count, perl=TRUE),
transistor_count = str_remove(transistor_count, "\\[[^\\]]*\\]"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_remove(transistor_count, "\\[[^\\]]*\\]"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_extract(transistor_count, "[:digit:]+"),
date_of_introduction = str_sub(date_of_introduction, 1, 4),
process = str_remove(process, ","),
process = str_extract(process, "[:digit:]+"),
area = str_extract(area, "[:digit:]+")
) %>%
mutate_at(.vars = vars(transistor_count:date_of_introduction, process:area), as.double)
df1_clean %>%
mutate()
df2 <- tables %>% chuck(2) %>%
janitor::clean_names() %>%
as_tibble()
df2_clean <- df2 %>%
mutate(
# transistor_count = gsub("\\[[^\\]]*\\]", "", transistor_count, perl=TRUE),
transistor_count = str_remove(transistor_count, "\\[[^\\]]*\\]"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_remove(transistor_count, "\\[[^\\]]*\\]"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_extract(transistor_count, "[:digit:]+"),
process = str_remove(process, ","),
process = str_extract(process, "[:digit:]+"),
area = str_extract(area, "[:digit:]+")
) %>%
mutate_at(.vars = vars(transistor_count:date_of_introduction, process:area), as.double)
df3 <- tables %>% chuck(4) %>%
janitor::clean_names() %>%
as_tibble()
df3
df3_clean <- df3 %>%
mutate(
# transistor_count = gsub("\\[[^\\]]*\\]", "", transistor_count, perl=TRUE),
transistor_count = str_remove(transistor_count, "\\[[^\\]]*\\]"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_remove(transistor_count, "\\[[^\\]]*\\]"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_remove(transistor_count, "[:punct:]+"),
transistor_count = str_extract(transistor_count, "[:digit:]+"),
date_of_introduction = if_else(
str_length(date_of_introduction) >= 5,
str_sub(date_of_introduction, -4),
str_sub(date_of_introduction, 1, 4)),
process = str_remove(process, ","),
process = str_extract(process, "[:digit:]+"),
area = str_extract(area, "[:digit:]+"),
bit_units = case_when(
str_detect(capacity_bits, "bit") ~ "Bits",
str_detect(capacity_bits, "kb") ~ "kb",
str_detect(capacity_bits, "Mb") ~ "Mb",
str_detect(capacity_bits, "Gb") ~ "Gb",
TRUE ~ ""
)
) %>%
mutate_at(.vars = vars(transistor_count:date_of_introduction, process:area), as.double) %>%
select(chip_name, capacity_bits, bit_units, everything()) %>%
mutate(capacity_bits = str_extract(capacity_bits, "[:digit:]+"))
df3_clean
write_csv(df1_clean, here::here("2019", "2019-09-03", "cpu.csv"))
write_csv(df2_clean, here::here("2019", "2019-09-03", "gpu.csv"))
write_csv(df3_clean, here::here("2019", "2019-09-03", "ram.csv"))
tomtom::create_dictionary(df1_clean)
cpu <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-09-03/cpu.csv")
gpu <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-09-03/gpu.csv")
ram <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-09-03/ram.csv")