-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Rhistory
165 lines (165 loc) · 8.04 KB
/
.Rhistory
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
getwd()
getwd()
setwd("~/Desktop/desktop [LOCAL]")
read.delim("BLI2013_low.csv")
BLI_l <- read.delim("BLI2013_low.csv",sep=",")
head(BLI_l)
BLI_h <- read.delim("BLI2013_ji.csv",sep=",")
dim(BLI_h)
levels(BLI_h$INDICATOR)
levels(BLI_h$Flags)
levels(BLI_h$MEASURE)
levels(BLI_h$Indicator)
levels(BLI_h[BLI_h$Flags=="","Country"])
table(BLI_h[BLI_h$Flags=="","Country"])
setwd(.)
setwd(~)
setwd(~/)
setwd("~")
getwd("")
getwd()
setwd("~/Google Drive/_CITY/JOM834_ScienceReporting/ContentAnalysis/Content Analysis II/part I - computational/contentanalysis")
load("DF_work.RData")
## identify the articles which did not have any mention any of the case-specific terms
DF_work1 <- DF_work
DF_work1[,c(9:85)] <- ifelse(DF_work[,c(9:85)]>0, 1, 0)
DF_work1$all <- apply(DF_work[,c(15:85)],1,sum)
DF_work1$yn <- ifelse(DF_work1$all>0, 1, 0)
## which terms were mentioned most?
df <- cbind.data.frame(names(DF_work1[,c(15:85)]),as.data.frame(apply(DF_work1[,c(15:85)], 2, sum)))
df[order(df[,2]),]
## visualise the results of the autmated text analysis
DF_vis <- DF_work1
DF_vis$weekday <- weekdays(as.Date(DF_vis$PUBDATE))
colLI <- c("#8c2d04","#ec7014","#fec44f")
colUK <- c("#8c96c6","#88419d","#2171b5")
library(ggplot2)
ggplot(DF_vis, aes(x=PUBWEEK, y=..count.., color=PUBL)) +
geom_point(stat="bin", size=4) +
geom_line(aes(x=PUBWEEK, y=..count..,group=PUBL, color=PUBL),stat="bin", position="identity") +
scale_color_manual(values=c(colLI,colUK)) +
#facet_wrap(~COUNTRY, nrow=2) +
ylab("article count") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
ggplot(ddply(DF_vis, .(PUBL,PUBWEEK), summarize, count_var=mean(all)),
aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
geom_point(stat="identity", size=4) +
geom_line(stat="identity", aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
scale_color_manual(values=c(colLI,colUK)) +
ylab("mention of W cases") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
ggplot(ddply(DF_vis, .(PUBL,PUBWEEK), summarize, count_var=mean(count_ebolavictim)),
aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
geom_point(stat="identity", size=4) +
geom_line(stat="identity", aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
scale_color_manual(values=c(colLI,colUK)) +
ylab("mention of 'ebola victim'") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
library(plyr)
ggplot(ddply(DF_vis, .(PUBL,PUBWEEK), summarize, count_var=mean(all)),
aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
geom_point(stat="identity", size=4) +
geom_line(stat="identity", aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
scale_color_manual(values=c(colLI,colUK)) +
ylab("mention of W cases") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
ggplot(DF_vis, aes(x=PUBWEEK, y=..count.., color=PUBL)) +
geom_point(stat="bin", size=4) +
geom_line(aes(x=PUBWEEK, y=..count..,group=PUBL, color=PUBL),stat="bin", position="identity") +
scale_color_manual(values=c(colLI,colUK)) +
#facet_wrap(~COUNTRY, nrow=2) +
ylab("article count") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
ggplot(DF_vis, aes(x=PUBWEEK, y=..count.., color=PUBL)) +
geom_point(stat="bin", size=4) +
geom_line(aes(x=PUBWEEK, y=..count..,group=PUBL, color=PUBL),stat="bin", position="identity") +
scale_color_manual(values=c(colLI,colUK)) +
#facet_wrap(~COUNTRY, nrow=2) +
ylab("article count/week") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
ggplot(DF_vis, aes(x=PUBWEEK, y=..count.., color=PUBL)) +
geom_point(stat="bin", size=4) +
geom_line(aes(x=PUBWEEK, y=..count..,group=PUBL, color=PUBL),stat="bin", position="identity") +
scale_color_manual(values=c(colLI,colUK)) +
#facet_wrap(~COUNTRY, nrow=2) +
ylab("article count / week") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
ggplot(ddply(DF_vis, .(PUBL,PUBWEEK), summarize, count_var=mean(all)),
aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
geom_point(stat="identity", size=4) +
geom_line(stat="identity", aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
scale_color_manual(values=c(colLI,colUK)) +
ylab("mention of W cases") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
load("DF_work.RData")
library(plyr)
library(ggplot2)
## identify the articles which did not have any mention any of the case-specific terms
DF_work1 <- DF_work
DF_work1[,c(9:85)] <- ifelse(DF_work[,c(9:85)]>0, 1, 0)
ggplot(ddply(DF_vis, .(PUBL,PUBWEEK), summarize, count_var=mean(all)),
aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
geom_point(stat="identity", size=4) +
geom_line(stat="identity", aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
scale_color_manual(values=c(colLI,colUK)) +
ylab("mention of W cases") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
ggplot(ddply(DF_vis, .(PUBL,PUBWEEK), summarize, count_var=mean(yr)),
aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
geom_point(stat="identity", size=4) +
geom_line(stat="identity", aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
scale_color_manual(values=c(colLI,colUK)) +
ylab("mention of W cases") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
DF_work1$yn <- ifelse(DF_work1$all>0, 1, 0) ## yn = if one of the terms was mentioned (all>0)
load("DF_work.RData")
library(plyr)
library(ggplot2)
## identify the articles which did not have any mention any of the case-specific terms
DF_work1 <- DF_work
DF_work1[,c(9:85)] <- ifelse(DF_work[,c(9:85)]>0, 1, 0) ## if it mentions one of the cases at least once, set value=1
DF_work1$all <- apply(DF_work[,c(15:85)],1,sum) ## all = sum = how many of the terms were mentioned
DF_work1$yn <- ifelse(DF_work1$all>0, 1, 0) ## yn = if one of the terms was mentioned (all>0)
## which terms were mentioned most?
df <- cbind.data.frame(names(DF_work1[,c(15:85)]),as.data.frame(apply(DF_work1[,c(15:85)], 2, sum)))
df[order(df[,2]),]
## visualise the results of the autmated text analysis
DF_vis <- DF_work1
DF_vis$weekday <- weekdays(as.Date(DF_vis$PUBDATE))
colLI <- c("#8c2d04","#ec7014","#fec44f")
colUK <- c("#8c96c6","#88419d","#2171b5")
library(ggplot2)
ggplot(ddply(DF_vis, .(PUBL,PUBWEEK), summarize, count_var=mean(yn)),
aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
geom_point(stat="identity", size=4) +
geom_line(stat="identity", aes(x=as.numeric(PUBWEEK), y=count_var, color=PUBL)) +
scale_color_manual(values=c(colLI,colUK)) +
ylab("mention of W cases") + xlab("Publication calendar week") +
theme(text=element_text(size=20), legend.position="top") +
guides(colour = guide_legend(nrow = 2, byrow = T, title=NULL))
summary(DF_vis$yn)
hist(DF_vis$yn)
table(DF_vis$yn)
table(DF_vis$yn, DF$vis$PUBL)
table(DF_vis$yn, DF_vis$PUBL)
ggplot2(DF_vis, aes(PUBL, fill=yn)) + geom_bar()
ggplot(DF_vis, aes(PUBL, fill=yn)) + geom_bar()
ggplot(DF_vis, aes(PUBL, ..count.., fill=yn)) + geom_bar()
ggplot(DF_vis, aes(PUBL)) + geom_bar()
ggplot(DF_vis, aes(PUBL, ..count..)) + geom_bar()
ggplot(DF_vis, aes(x=PUBL, y=..count..)) + geom_bar()
ggplot(DF_vis, aes(x=PUBL, y=..count..)) + geom_bar(stat="bin")
ggplot(DF_vis, aes(x=PUBWEEK, y=..count.., color=PUBL)) +
geom_point(stat="bin", size=4)
ggplot(DF_vis, aes(x=PUBWEEK, y=..count.., color=PUBL)) +
geom_point(stat="bin", size=4)