-
Notifications
You must be signed in to change notification settings - Fork 0
/
BibAnalysis-Cleaner.R
138 lines (120 loc) · 5.43 KB
/
BibAnalysis-Cleaner.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
### SECONDARY SOURCES ###
#Read in txt file and separate each line of Sims Bibliography (http://normansims.com/wp-content/uploads/2014/05/Bibliography-of-Literary-Journalism-Scholarship-and-Articles.pdf)
SimsBib = scan("data/SimsBib.txt", character(0), sep = "\n")
SimsBibDF = SimsBib %>% data.frame()
SimsBibDF = SimsBibDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
SimsBibDF = SimsBibDF %>% mutate("Year" = as.numeric(Year))
SimsBibDF = SimsBibDF %>% mutate(author=gsub("(^[A-Za-z]{1,20}).*","\\1",.))
SimsBibDF = SimsBibDF %>% unite(id, author, Year, sep = "_")
SimsBibDF = SimsBibDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
SimsBibDF = SimsBibDF %>% mutate("Year" = as.numeric(Year))
names(SimsBibDF)[names(SimsBibDF)=="."] <- "fullCit"
#Read in txt file and separate each line of LJS Bibliography (https://www.dropbox.com/s/3a1wilg8lxngag5/LJS_Biblio_v120301.pdf?dl=0)
LJBib = scan("data/LJSBib.txt", character(0), sep = "\n")
LJBibDF = LJBib %>% data.frame()
LJBibDF = LJBibDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJBibDF = LJBibDF %>% mutate("Year" = as.numeric(Year))
LJBibDF = LJBibDF %>% mutate(author=gsub("(^[A-Za-z]{1,20}).*","\\1",.))
LJBibDF = LJBibDF %>% unite(id, author, Year, sep = "_")
LJBibDF = LJBibDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJBibDF = LJBibDF %>% mutate("Year" = as.numeric(Year))
names(LJBibDF)[names(LJBibDF)=="."] <- "fullCit"
#Read in txt file and separate each line of LJS Bibliography (Fall 2011) (http://ialjs.journalism.ryerson.ca/wp-content/uploads/2012/01/125-127_SelectedBibliographyMaguire-2.pdf)
LJBib2 = scan("data/LJSBib2.txt", character(0), sep = "\n")
LJBib2DF = LJBib2 %>% data.frame()
LJBib2DF = LJBib2DF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJBib2DF = LJBib2DF %>% mutate("Year" = as.numeric(Year))
LJBib2DF = LJBib2DF %>% mutate(author=gsub("(^[A-Za-z]{1,20}).*","\\1",.))
LJBib2DF = LJBib2DF %>% unite(id, author, Year, sep = "_")
LJBib2DF = LJBib2DF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJBib2DF = LJBib2DF %>% mutate("Year" = as.numeric(Year))
names(LJBib2DF)[names(LJBib2DF)=="."] <- "fullCit"
#Combine Sims and LJS Bibs [LETS DO THIS AT THE END]
secondary <- rbind(LJBibDF, SimsBibDF, LJBib2DF)
secondary = distinct(secondary, id, Year, fullCit)
secondary = secondary %>%
filter(Year>1850) %>%
group_by(Year) %>%
mutate(count=n()) %>%
mutate(Source = "Critical Works") %>%
mutate(fullCit = as.character(fullCit))
#visualize
secondary %>%
filter(Year>1880) %>%
ggplot() +
geom_line() +
aes(x=Year,y=count, color=Source) +
geom_point(alpha=.8) +
ggtitle("Number of Critical Works of Literary Journalism Published by Year") +
theme_bw(base_size = 20)
### PRIMARY SOURCES ###
#Read in txt file and separate each line of Primary (for Sims bibliography)
LJPrim = scan("data/LJPrimary.txt", character(0), sep = "\n")
LJPrimDF = LJPrim %>% data.frame()
LJPrimDF = LJPrimDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJPrimDF = LJPrimDF %>% mutate("Year" = as.numeric(Year))
LJPrimDF = LJPrimDF %>% mutate(author=gsub("(^[A-Za-z]{1,20}).*","\\1",.))
LJPrimDF = LJPrimDF %>% unite(id, author, Year, sep = "_")
LJPrimDF = LJPrimDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJPrimDF = LJPrimDF %>% mutate("Year" = as.numeric(Year))
names(LJPrimDF)[names(LJPrimDF)=="."] <- "fullCit"
#Read in txt file and separate each line of Primary (from Art of Fact TOC)
LJtoc = scan("data/ArtofFactTOC.txt", character(0), sep = "\n")
LJtocDF = LJtoc %>% data.frame()
LJtocDF = LJtocDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJtocDF = LJtocDF %>% mutate("Year" = as.numeric(Year))
LJtocDF = LJtocDF %>% mutate(author=gsub(".*( / )","\\1",.))
LJtocDF = LJtocDF %>% mutate(author=gsub("( --).*","\\1",LJtocDF$author))
LJtocDF = LJtocDF %>% mutate(author=gsub("[[:punct:]]","\\1",LJtocDF$author))
LJtocDF = LJtocDF %>% mutate(author=gsub(".*( [A-Z])","\\1",LJtocDF$author))
LJtocDF = LJtocDF %>% mutate(author=gsub(" ","\\1",LJtocDF$author))
LJtocDF = LJtocDF %>% unite(id, author, Year, sep = "_")
LJtocDF = LJtocDF %>% mutate(Year=gsub(".*(\\d{4}).*","\\1",.))
LJtocDF = LJtocDF %>% mutate("Year" = as.numeric(Year))
names(LJtocDF)[names(LJtocDF)=="."] <- "fullCit"
#Combine primary sources
primary <- rbind(LJtocDF, LJPrimDF)
primary = distinct(primary, id, Year, fullCit)
primary = primary %>%
filter(Year>1850) %>%
group_by(Year) %>%
mutate(count=n()) %>%
mutate(Source = "Primary Works") %>%
mutate(fullCit = as.character(fullCit))
#visualize (line and point)
primary %>%
filter(Year>1880) %>%
ggplot() +
geom_line() +
aes(x=Year,y=count, color=Source) +
geom_point(alpha=.8) +
ggtitle("Number of Primary Works of Literary Journalism Published by Year") +
theme_bw(base_size = 20)
#visualize (bar)
primary %>%
filter(Year>1880) %>%
ggplot() +
geom_bar() +
aes(x=Year) +
ggtitle("Number of Primary Works of Literary Journalism Published by Year") +
theme_bw(base_size = 20)
### COMBINED ###
bibAndPrim <- rbind(primary, secondary)
#visualize
bibAndPrim %>%
filter(Year>1880) %>%
ggplot() +
geom_line() +
aes(x=Year,y=count, color=Source) +
geom_point(alpha=.8) +
ggtitle("Number of Primary and Critical Works of Literary Journalism Published by Year") +
theme_bw(base_size = 20)
bibAndPrim %>%
filter(Year>1880, Year<2000) %>%
ggplot() +
geom_histogram() +
aes(x=Year,fill=Source) +
ggtitle("Number of Primary and Critical Works of Literary Journalism Published by Year") +
theme_bw(base_size = 20)
#clear all
rm(list=ls())