-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analyze Ownership Categories.R
77 lines (62 loc) · 2.33 KB
/
Analyze Ownership Categories.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
library(tidyverse)
df <- read_csv("data/20191126_Patents_Ownership-Category_long.csv")
df_grant <- df %>% filter(year_type == "Grant year")
df_app <- df %>% filter(year_type == "Application year")
df_grant %>%
filter(ownership_category == "U.S. CORPORATION") %>%
ggplot(aes(x = year, y = patent_count)) +
geom_col()
df_app %>%
filter(ownership_category == "U.S. CORPORATION") %>%
ggplot(aes(x = year, y = patent_count)) +
geom_col()
df %>%
filter(ownership_category == "U.S. CORPORATION") %>%
ggplot(aes(x = year, y = patent_count, fill = year_type)) +
geom_col() +
facet_wrap(~ year_type)
df %>%
filter(str_ends(ownership_category, "CORPORATION"),
year > 1990) %>%
ggplot(aes(x = year, y = patent_count, color = year_type)) +
geom_line() +
facet_wrap(~ ownership_category)
# ---------------------------------------------
# Individual
# ---------------------------------------------
df %>%
filter(ownership_category == "U.S. INDIVIDUAL", year > 1990) %>%
ggplot(aes(x = year, y = patent_count, color = year_type)) +
geom_line() + geom_point()
df %>%
filter(ownership_category == "FOREIGN INDIVIDUAL", year > 1990) %>%
ggplot(aes(x = year, y = patent_count, color = year_type)) +
geom_line() + geom_point()
df %>%
filter(str_ends(ownership_category, "INDIVIDUAL"),
year > 1990) %>%
ggplot(aes(x = year, y = patent_count, color = year_type)) +
geom_line() + geom_point() +
facet_wrap(~ ownership_category)
# =============================================
# Government
# =============================================
df %>%
filter(str_ends(ownership_category, "GOVERNMENT"), year > 1970) %>%
ggplot(aes(x = year, y = patent_count, color = year_type)) +
geom_line() + geom_point() +
facet_wrap(~ ownership_category)
# =============================================
# Compare all categories
# =============================================
df %>%
filter(year > 1970, year_type == "Grant year") %>%
ggplot(aes(x = year, y = patent_count)) +
geom_col(aes(fill = ownership_category),
position = "fill")
df %>%
filter(year > 1970) %>%
ggplot(aes(x = year, y = patent_count)) +
geom_col(aes(fill = ownership_category), position = "fill") +
facet_wrap(~ year_type) +
theme(legend.position = "bottom")