forked from stathack/Presidential-Semantic-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 24.1 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
repeat {
startTime <- Sys.time()
source('~/Presidential-Semantic-Analysis/debate.R')
sleepTime <- startTime + 1*60 - Sys.time(source('~/Presidential-Semantic-Analysis/debate.R'))
if (sleepTime > 0)
Sys.sleep(sleepTime)
}
repeat {
startTime <- Sys.time()
source('~/Presidential-Semantic-Analysis/debate.R')
sleepTime <- startTime + 1*60 - Sys.time()
if (sleepTime > 0)
Sys.sleep(sleepTime)
}
repeat {
startTime <- Sys.time()
source('~/Presidential-Semantic-Analysis/debate.R')
sleepTime <- startTime + 1*60 - Sys.time()
if (sleepTime > 0)
Sys.sleep(sleepTime)
}
View(debate)
fix(president)
system.time(Romney=searchTwitter('@MittRomney', n=1500))
system.time(searchTwitter('@MittRomney', n=1500))
install.packages("multicore")
library("multicore")
install.packages("doMC")
detectcores()
Sys.getenv('NUMBER_OF_PROCESSORS')
multicore:::detectCores()
registerDoMC(cores=2)
library("doMC")
registerDoMC(cores=2)
install.packages("foreach")
getDoParWorkers()
min.v<-5
max.v<-10
a<-list('MittRomney','BarackObama','PaulRyanVP','JoeBiden')
a
fix(`m6`)
vp<-function(y){
a<-list('MittRomney','BarackObama','PaulRyanVP','JoeBiden')
for(z in a){
z=searchTwitter(cat("\"@", z,"\"", sep=""), n=1500)
}
x<- do.call(rbind, a)
return(x)
}
system.time(vp())
cat("\"@", min.v,"\"", sep="")
for(z in a){
z=searchTwitter(cat("\"@", z,"\"", sep=""), n=1500)
}
paste("\"@", min.v,"\"", sep="")
paste(""@", min.v,""", sep="")
cat("\"@", min.v,"\"", sep="")
paste("\'@", min.v,"\'", sep="")
paste("\'@", min.v,"\'")
cat("\'@", min.v,"\'", sep="")
for(z in a){
z=searchTwitter( cat("\'@", z,"\'", sep=""), n=1500)
}
for(z in a){
z=searchTwitter( paste("\'@", z,"\'", sep=""), n=1500)
}
vp<-function(y){
a<-list('MittRomney','BarackObama','PaulRyanVP','JoeBiden')
for(z in a){
z=searchTwitter( paste("\'@", z,"\'", sep=""), n=1500)
}
x<- do.call(rbind, a)
return(x)
}
x<-vp()
View(x)
fix(vp)
x<-vp()
fix(vp)
x<-vp()
fix(vp)
x<-vp()
z<-("MittRomney")
fix(vp)
Romney<-searchTwitter( cat("\'@", z,"\'", sep=""), n=1500)
Romney<-searchTwitter( paste("\'@", z,"\'", sep=""), n=1500)
gsub("\"","'","I'm watching \"Prometheus\".")
gsub("\"","'","I'm watching \"",z,"\".")
x
z
gsub("\"","'",z,"\".")
gsub("\"","'@",z,"\".")
fix(vp)
source('~/Presidential-Semantic-Analysis/vp.R', echo=TRUE)
vp<-function(y){
Romney=searchTwitter('@MittRomney', n=1500)
Obama=searchTwitter('@BarackObama', n=1500)
Ryan=searchTwitter('@PaulRyanVP', n=1500)
Biden=searchTwitter('@JoeBiden', n=1500)
x<- rbind(Romney, Obama, Ryan, Biden)
return(x)
}
system.time(vp())
dQuote(paste(min.v, max.v))
dQuote(paste(min.v,"@", max.v))
Romney<-searchTwitter(dQuote(paste("@", z)), n=1500)
vp<-function(y){
a<-list('MittRomney','BarackObama','PaulRyanVP','JoeBiden')
for(z in a){
z=searchTwitter(dQuote(paste("@", z)), n=1500)
}
x<- do.call(rbind, a)
return(x)
}
system.time(vp())
fix(vp)
fix(vp)
fix(vp)
system.time(vp())
vp<-function(y){
Romney=searchTwitter('@MittRomney', n=1500)
Obama=searchTwitter('@BarackObama', n=1500)
Ryan=searchTwitter('@PaulRyanVP', n=1500)
Biden=searchTwitter('@JoeBiden', n=1500)
x<- rbind(Romney, Obama, Ryan, Biden)
return(x)
}
debate<-vp()
repeat {
startTime <- Sys.time()
x<-vp()
debate<-merge(x, debate, all=TRUE)
sleepTime <- startTime + 1*60 - Sys.time()
if (sleepTime > 0)
Sys.sleep(sleepTime)
}
View(debate)
fix(vp)
debate<-vp()
View(debate)
fix(vp)
debate<-vp()
fix(vp)
debate<-vp()
fix(vp)
debate<-vp()
summary(m7)
summary(m6)
library("lme4")
summary(m6)
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + dishwasher + elevator + granite + gym + hardwood + loft + luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) | zip) + (sqft | zip) + (doorman | zip) + roof:deck + sqft:condo + elevator:brick + roof:terrace + hardwood:luxury + loft:doorman + beds:loft + dishwasher:renovated + furnished:central_air + granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE)
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + dishwasher + elevator + granite + gym + hardwood + loft + luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) | zip) + (sqft | zip) + (doorman | zip) + roof:deck + sqft:condo + elevator:brick + roof:terrace + hardwood:luxury + loft:doorman + beds:loft + dishwasher:renovated + furnished:central_air + granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600)))
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + dishwasher + elevator + granite + gym + hardwood + loft + luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) | zip) + (sqft | zip) + (doorman | zip) + roof:deck + sqft:condo + elevator:brick + roof:terrace + hardwood:luxury + loft:doorman + beds:loft + dishwasher:renovated + furnished:central_air + granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + dishwasher +
elevator + granite + gym + hardwood + loft +
luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) |
zip) + (sqft | zip) + (doorman | zip) +
roof:deck + sqft:condo + elevator:brick +
roof:terrace + hardwood:luxury + loft:doorman + beds:loft +
dishwasher:renovated + furnished:central_air +
granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE);summary(m7)
formula(m6)
m7<-lmer(price ~ sqft + beds + factor(baths) + dishwasher + elevator + granite + gym + hardwood + loft + luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) | zip) + (sqft | zip) + (doorman | zip) + roof:deck + sqft:condo + elevator:brick + roof:terrace + hardwood:luxury + loft:doorman + beds:loft + dishwasher:renovated + furnished:central_air + granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + dishwasher + elevator + granite + gym + hardwood + loft + luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) | zip) + (sqft | zip) + roof:deck + sqft:condo + elevator:brick + roof:terrace + hardwood:luxury + loft:doorman + beds:loft + dishwasher:renovated + furnished:central_air + granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + dishwasher + elevator + granite + gym + hardwood + loft + luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) | zip) + (sqft | zip) + roof:deck + sqft:condo + elevator:brick + hardwood:luxury + loft:doorman + beds:loft + dishwasher:renovated + furnished:central_air + granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + dishwasher + elevator + granite + gym + hardwood + loft + luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) | zip) + (sqft | zip) + roof:deck + sqft:condo + elevator:brick + hardwood:luxury + loft:doorman + beds:loft + dishwasher:renovated + furnished:central_air + granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
summary(m5)
warnings(m5)
warnings(m4)
warnings(m3)
warnings(m2)
warnings(m1)
warnings(a)
formula(m5)
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + condo + dishwasher +
elevator + furnished + granite + gym + hardwood + loft +
luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) |
zip) + (sqft | zip) + (doorman | zip) + (balcony | zip) +
(condo | zip) + roof:deck + sqft:condo + elevator:brick +
roof:terrace + hardwood:luxury + loft:doorman + beds:loft +
dishwasher:renovated + balcony:elevator + sqft:loft + furnished:central_air +
granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
summary(m7)
m7<-lmer(price ~ sqft + beds + factor(baths) + condo + dishwasher +
elevator + furnished + granite + gym + hardwood + loft +
luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) |
zip) + (sqft | zip) + (doorman | zip) + (balcony | zip) +
(condo | zip) + roof:deck + sqft:condo + elevator:brick +
roof:terrace + hardwood:luxury + loft:doorman + beds:loft +
dishwasher:renovated + balcony:elevator + sqft:loft + furnished:central_air +
granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + condo + dishwasher +
elevator + furnished + granite + gym + hardwood + loft +
luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) |
zip) + (sqft | zip) + (doorman | zip) + (balcony | zip) +
(condo | zip) + roof:deck + sqft:condo + elevator:brick +
roof:terrace + hardwood:luxury + loft:doorman + beds:loft +
dishwasher:renovated + balcony:elevator + sqft:loft + furnished:central_air +
granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
coef(m7)[[1]]
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + condo + dishwasher +
elevator + furnished + granite + gym + hardwood + loft +
luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) |
zip) + (sqft | zip) +doorman + (balcony | zip) +
(condo | zip) + roof:deck + sqft:condo + elevator:brick +
roof:terrace + hardwood:luxury + loft:doorman + beds:loft +
dishwasher:renovated + balcony:elevator + sqft:loft + furnished:central_air +
granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
m7<-lmer(price ~ sqft + beds + factor(baths) + balcony + condo + dishwasher +
elevator + furnished + granite + gym + hardwood + loft +
luxury + stainless + (1 | zip) + (beds | zip) + (factor(baths) |
zip) + (sqft | zip) + (balcony | zip) +
(condo | zip) + roof:deck + sqft:condo + elevator:brick +
roof:terrace + hardwood:luxury + loft:doorman + beds:loft +
dishwasher:renovated + balcony:elevator + sqft:loft + furnished:central_air +
granite:laundry + gym:terrace + loft:roof:deck, data=eeg, verbose=TRUE,control = list(maxIter=600))
coef(m7)[[1]]
x<-coef(m7)[[1]]
setwd("~/Dropbox/rstudio/Philly Models")
write.csv(x, file="phillycoefs10112012.csv")
fix(vp)
vp<-function(x){
Ryan=searchTwitter('@PaulRyanVP', n=1500)
Biden=searchTwitter('@JoeBiden', n=1500)
textRyan=laply(Ryan, function(t) t$getText())
textBiden=laply(Biden, function(t) t$getText())
resultRyan=score.sentiment(textRyan, positive.words, negative.words)
resultRyan$candidate='Ryan'
resultBiden=score.sentiment(textBiden, positive.words, negative.words)
resultBiden$candidate='Biden'
result<-merge(resultBiden,resultRyan, all=TRUE)
result$candidate<-as.factor(result$candidate)
result$time<-date()
return(result)
}
debate<-vp()
repeat {
startTime <- Sys.time()
x<-vp()
debate<-merge(x, debate, all=TRUE)
sleepTime <- startTime + 1*60 - Sys.time()
if (sleepTime > 0)
Sys.sleep(sleepTime)
}
View(debate)
Ryan=searchTwitter('@PaulRyanVP', n=1500)
Ryan=searchTwitter('@PaulRyanVP', '@RepPaulRyan', n=1500)
Ryan=searchTwitter('@RepPaulRyan', n=1500)
repeat {
startTime <- Sys.time()
x<-vp()
debate<-merge(x, debate, all=TRUE)
sleepTime <- startTime + 1*60 - Sys.time()
if (sleepTime > 0)
Sys.sleep(sleepTime)
}
View(debate)
View(debate)
View(debate)
length(factor(debate$text))
levels(factor(debate$text))
length(levels(factor(debate$text)))
setwd("~/Presidential-Semantic-Analysis")
write.csv(debate, file="vpdebate10112012.csv")
x<-subset(debate, !duplicated(text))
View(x)
summary(factor(x$candidate))
summary(factor(x$time))
install.packages("lubridate")
library("lubridate")
x$minute<-minute(x$time)
x$minute<-as.POSIXlt(x$time)
class(x$time)
x$minute<-$as.POSIXct(x$time,format="%H:%M")
x$minute<-as.POSIXct(x$time,format="%H:%M")
summary(factor(x$minute))
length(levels(factor(x$time)))
min(x$time)
max(x$time)
period <-min(x$time):max(x$time)
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,xlim = as.Date(c("Thu Oct 11 21:00:00 2012","Thu Oct 11 22:31:00 2012")),ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period <-as.date(min(x$time):max(x$time))
x$minute<-as.time(x$time)
date()
time()
x$minute<-as.Date(x$time, "%m/%d/%Y %H:%M:%S")
View(x)
x$minute<-mdy(x$time)
x$minute<-parse_date_time(x$time)
Time<-strptime(x$time,format="&m/%d/%Y %H:$M")
Time
head(x$time)
x$minute<-strptime(x$time, "%a %b %d %H:%M:%S %Y")
View(x)
x$minute1<-minute(x$time)
class(x$minute)
period <-min(x$time):max(x$time)
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period <-min(x$minute):max(x$minute)
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period <-as.POSIXct(min(x$minute):max(x$minute))
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
x$minute1<-strptime(x$time, format="%H:%M")
View(x)
x$minute1<-format(strptime("1970-01-01", "%Y-%m-%d", tz="UTC") + round(as.numeric(x$minute)/60)*60,"%H:%M")
View(x)
a <-as.POSIXlt(x$time)
a <-as.POSIXt(x$time)
a <-as.POSIXlt(x$minute)
a
a<-minute(a)
a
a<-as.time(a)
x$minute1<-format(x$minute,"%H:%M")
View(x)
period <-as.POSIXct(min(x$minute1):max(x$minute1))
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period <-as.time(min(x$minute1):max(x$minute1))
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period <-as.date(min(x$minute1):max(x$minute1))
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(as.yearmon(minute))
period<-period[order(period)]
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique((minute))
period<-period[order(period)]
Biden <- sapply(period, function(x) mean((d[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(d[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute)
period<-period[order(period)]
Biden <- sapply(period, function(x) mean((x[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(x) mean(x[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate="Biden", 'score'])))
Ryan <- sapply(period, function(y) mean(x[x$candidate="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden", 'score'])))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan", 'score'])))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden", 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan", 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
Ryan
period
period<-unique(x$minute)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden", 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan", 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden", 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan", 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden" & y==x$minute, 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan" & y==x$minute, 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute1)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden" & y==x$minute1, 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan" & y==x$minute1, 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
plot=qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(x$minute1)
period<-period[order(period)]
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden" & y==x$minute1, 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan" & y==x$minute1, 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
View(mean)
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")+
+ scale_colour_manual(values=c("#330000","#FFFF00"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")
no
ggplot(dfm)+geom_line(aes(x=period,y=value,colour=variable)) +
scale_colour_manual(values=c("#330000","#FFFF00"))
class(mean$period)
time<-as.time(mean$period)
format(mean$period,"%H:%M")
View(dfm)
ggplot(mean)+geom_line(aes(x=period,y=value,colour=variable)) +
scale_colour_manual(values=c("#330000","#FFFF00"))
ggplot(mean)+geom_line(aes(x=period,y=score,colour=variable)) +
scale_colour_manual(values=c("#330000","#FFFF00"))
ggplot(mean)+geom_line(aes(x=mean$period,y=meanscore,colour=variable)) +
scale_colour_manual(values=c("#330000","#FFFF00"))
ggplot(mean)+geom_line(aes(x=mean$period,y=mean$score,colour=variable)) +
scale_colour_manual(values=c("#330000","#FFFF00"))
ggplot(mean)+geom_line(aes(x=mean$period,y=mean$score)) +
scale_colour_manual(values=c("#330000","#FFFF00"))
time<-as.POSIXlt((mean$period)
)
time<-as.POSIXt((mean$period)
)
class(period)
period<-format(unique(x$minute1),"%H:%M")
period<-format(period[order(period)],"%H:%M")
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden" & y==x$minute1, 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan" & y==x$minute1, 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
period<-unique(format(x$minute1,"%H:%M"))
period<-format(period[order(period)],"%H:%M")
Biden <- sapply(period, function(y) mean(x[x$candidate=="Biden" & y==x$minute1, 'score']))
Ryan <- sapply(period, function(y) mean(x[x$candidate=="Ryan" & y==x$minute1, 'score']))
mean<-data.frame(period, Biden, Ryan)
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "time",ylab="Average score")+
scale_colour_manual(values=c("#330000","#FFFF00"))
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = n,ylab="Average Price")+
scale_colour_manual(values=c("#330000","#FFFF00"))
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "score",ylab="Average Price")+
scale_colour_manual(values=c("#330000","#FFFF00"))
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "score",ylab="Average Price", group=1)+
scale_colour_manual(values=c("#330000","#FFFF00"))
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "score",ylab="Average Price", group=2)+
scale_colour_manual(values=c("#330000","#FFFF00"))
dfm <- melt(mean, id = "period", measure = c("Biden", "Ryan"))
qplot(period, value, data=dfm, geom="line", colour = variable,xlab = "score",ylab="Average Price", group="variable")+
scale_colour_manual(values=c("#330000","#FFFF00"))
ggplot(dfm, aes(period, value, colour=variable, group=variable)) +
geom_point() + geom_line()
dfm <- melt(mean, id = "period", measure = c("Ryan", "Biden"))
ggplot(dfm, aes(period, value, colour=variable, group=variable)) +
geom_point() + geom_line()
ggplot(dfm, aes(period, value, colour=variable, group=variable), xlab="time", ylab="score") +
geom_point() + geom_line()
ggplot(dfm, aes(period, value, colour=variable, group=variable, xlab="time", ylab="score")) +
geom_point() + geom_line()