Skip to content

Instantly share code, notes, and snippets.

@DrSkippy
Created January 25, 2012 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrSkippy/1677967 to your computer and use it in GitHub Desktop.
Save DrSkippy/1677967 to your computer and use it in GitHub Desktop.
R script for plotting pulse of social activity with pulse function fit
ts1 ngFit ts2 twFit timestamp date twitter newsgator
1326696009.000000 0.000000 1326696009.000000 0.000000 1326696009 1/16/12 1:40 0 1
1326696069.000000 0.000000 1326696069.000000 0.000000 1326696069 1/16/12 1:41 3 0
1326696129.000000 0.000000 1326696129.000000 0.000000 1326696129 1/16/12 1:42 7 0
1326696189.000000 0.000000 1326696189.000000 0.000000 1326696189 1/16/12 1:43 5 0
1326696249.000000 0.000000 1326696249.000000 0.000000 1326696249 1/16/12 1:44 1 0
1326696309.000000 0.000000 1326696309.000000 0.000000 1326696309 1/16/12 1:45 2 0
1326696369.000000 0.000000 1326696369.000000 0.000000 1326696369 1/16/12 1:46 1 0
1326696429.000000 0.000000 1326696429.000000 0.000000 1326696429 1/16/12 1:47 0 0
1326696489.000000 0.000000 1326696489.000000 0.000000 1326696489 1/16/12 1:48 2 0
1326696549.000000 0.000000 1326696549.000000 0.000000 1326696549 1/16/12 1:49 1 1
1326696609.000000 0.000000 1326696609.000000 0.000000 1326696609 1/16/12 1:50 3 0
1326696669.000000 0.000000 1326696669.000000 0.000000 1326696669 1/16/12 1:51 3 0
1326696729.000000 0.000000 1326696729.000000 0.000000 1326696729 1/16/12 1:52 0 0
1326696789.000000 0.000000 1326696789.000000 0.000000 1326696789 1/16/12 1:53 4 0
1326696849.000000 0.000000 1326696849.000000 0.000000 1326696849 1/16/12 1:54 1 0
1326696909.000000 0.000000 1326696909.000000 0.000000 1326696909 1/16/12 1:55 3 0
1326696969.000000 0.000000 1326696969.000000 0.000000 1326696969 1/16/12 1:56 2 0
1326697029.000000 0.000000 1326697029.000000 0.000000 1326697029 1/16/12 1:57 1 0
1326697089.000000 0.000000 1326697089.000000 0.000000 1326697089 1/16/12 1:58 0 0
1326697149.000000 0.000000 1326697149.000000 0.000000 1326697149 1/16/12 1:59 0 0
1326697209.000000 0.000000 1326697209.000000 0.000000 1326697209 1/16/12 2:00 2 0
1326697269.000000 0.000000 1326697269.000000 0.000000 1326697269 1/16/12 2:01 4 0
1326697329.000000 0.000000 1326697329.000000 0.000000 1326697329 1/16/12 2:02 1 0
1326697389.000000 0.000000 1326697389.000000 0.000000 1326697389 1/16/12 2:03 1 0
1326697449.000000 0.000000 1326697449.000000 0.000000 1326697449 1/16/12 2:04 1 0
1326697509.000000 0.000000 1326697509.000000 0.000000 1326697509 1/16/12 2:05 2 0
1326697569.000000 0.000000 1326697569.000000 0.000000 1326697569 1/16/12 2:06 1 0
1326697629.000000 0.000000 1326697629.000000 0.000000 1326697629 1/16/12 2:07 3 0
1326697689.000000 0.000000 1326697689.000000 0.000000 1326697689 1/16/12 2:08 1 0
1326697749.000000 0.000000 1326697749.000000 0.000000 1326697749 1/16/12 2:09 3 0
1326697809.000000 0.000000 1326697809.000000 0.000000 1326697809 1/16/12 2:10 1 0
1326697869.000000 0.000000 1326697869.000000 0.000000 1326697869 1/16/12 2:11 0 0
1326697929.000000 0.000000 1326697929.000000 0.000000 1326697929 1/16/12 2:12 3 0
1326697989.000000 0.000000 1326697989.000000 0.000000 1326697989 1/16/12 2:13 5 0
1326698049.000000 0.000000 1326698049.000000 0.000000 1326698049 1/16/12 2:14 60 0
1326698109.000000 0.000000 1326698109.000000 179.150818 1326698109 1/16/12 2:15 194 0
1326698169.000000 0.000000 1326698169.000000 326.041394 1326698169 1/16/12 2:16 288 0
1326698229.000000 0.000000 1326698229.000000 424.276992 1326698229 1/16/12 2:17 364 0
1326698289.000000 0.000000 1326698289.000000 488.926296 1326698289 1/16/12 2:18 552 0
1326698349.000000 0.000000 1326698349.000000 530.407206 1326698349 1/16/12 2:19 641 0
1326698409.000000 0.000000 1326698409.000000 555.921988 1326698409 1/16/12 2:20 652 0
1326698469.000000 0.000000 1326698469.000000 570.449566 1326698469 1/16/12 2:21 522 0
1326698529.000000 0.127703 1326698529.000000 577.431616 1326698529 1/16/12 2:22 491 0
1326698589.000000 0.270056 1326698589.000000 579.246939 1326698589 1/16/12 2:23 490 0
1326698649.000000 0.386077 1326698649.000000 577.539457 1326698649 1/16/12 2:24 487 1
1326698709.000000 0.479876 1326698709.000000 573.444997 1326698709 1/16/12 2:25 532 0
1326698769.000000 0.554941 1326698769.000000 567.748092 1326698769 1/16/12 2:26 517 0
1326698829.000000 0.614230 1326698829.000000 560.990393 1326698829 1/16/12 2:27 562 3
1326698889.000000 0.660252 1326698889.000000 553.545633 1326698889 1/16/12 2:28 578 0
1326698949.000000 0.695136 1326698949.000000 545.671455 1326698949 1/16/12 2:29 546 0
1326699009.000000 0.720685 1326699009.000000 537.545249 1326699009 1/16/12 2:30 523 1
1326699069.000000 0.738428 1326699069.000000 529.288926 1326699069 1/16/12 2:31 536 1
1326699129.000000 0.749659 1326699129.000000 520.986052 1326699129 1/16/12 2:32 590 1
1326699189.000000 0.755475 1326699189.000000 512.693691 1326699189 1/16/12 2:33 540 0
1326699249.000000 0.756804 1326699249.000000 504.450596 1326699249 1/16/12 2:34 590 0
1326699309.000000 0.754430 1326699309.000000 496.282870 1326699309 1/16/12 2:35 532 0
1326699369.000000 0.749018 1326699369.000000 488.207882 1326699369 1/16/12 2:36 529 0
1326699429.000000 0.741128 1326699429.000000 480.236972 1326699429 1/16/12 2:37 551 0
1326699489.000000 0.731232 1326699489.000000 472.377323 1326699489 1/16/12 2:38 553 1
1326699549.000000 0.719730 1326699549.000000 464.633255 1326699549 1/16/12 2:39 543 1
1326699609.000000 0.706958 1326699609.000000 457.007119 1326699609 1/16/12 2:40 530 2
1326699669.000000 0.693198 1326699669.000000 449.499915 1326699669 1/16/12 2:41 564 3
1326699729.000000 0.678687 1326699729.000000 442.111717 1326699729 1/16/12 2:42 461 1
1326699789.000000 0.663624 1326699789.000000 434.841972 1326699789 1/16/12 2:43 413 0
1326699849.000000 0.648175 1326699849.000000 427.689704 1326699849 1/16/12 2:44 448 0
1326699909.000000 0.632480 1326699909.000000 420.653651 1326699909 1/16/12 2:45 396 2
1326699969.000000 0.616653 1326699969.000000 413.732365 1326699969 1/16/12 2:46 376 0
1326700029.000000 0.600790 1326700029.000000 406.924277 1326700029 1/16/12 2:47 279 0
1326700089.000000 0.584971 1326700089.000000 400.227747 1326700089 1/16/12 2:48 305 0
1326700149.000000 0.569260 1326700149.000000 393.641093 1326700149 1/16/12 2:49 325 0
1326700209.000000 0.553710 1326700209.000000 387.162611 1326700209 1/16/12 2:50 428 1
1326700269.000000 0.538364 1326700269.000000 380.790596 1326700269 1/16/12 2:51 347 1
1326700329.000000 0.523256 1326700329.000000 374.523345 1326700329 1/16/12 2:52 402 0
1326700389.000000 0.508414 1326700389.000000 368.359169 1326700389 1/16/12 2:53 363 1
1326700449.000000 0.493858 1326700449.000000 362.296396 1326700449 1/16/12 2:54 354 2
1326700509.000000 0.479606 1326700509.000000 356.333375 1326700509 1/16/12 2:55 371 1
1326700569.000000 0.465668 1326700569.000000 350.468473 1326700569 1/16/12 2:56 313 0
1326700629.000000 0.452053 1326700629.000000 344.700085 1326700629 1/16/12 2:57 340 0
1326700689.000000 0.438767 1326700689.000000 339.026628 1326700689 1/16/12 2:58 291 1
1326700749.000000 0.425812 1326700749.000000 333.446543 1326700749 1/16/12 2:59 263 0
1326700809.000000 0.413190 1326700809.000000 327.958295 1326700809 1/16/12 3:00 237 0
1326700869.000000 0.400900 1326700869.000000 322.560375 1326700869 1/16/12 3:01 238 0
1326700929.000000 0.388939 1326700929.000000 317.251298 1326700929 1/16/12 3:02 386 0
1326700989.000000 0.377304 1326700989.000000 312.029602 1326700989 1/16/12 3:03 313 0
1326701049.000000 0.365992 1326701049.000000 306.893850 1326701049 1/16/12 3:04 253 1
1326701109.000000 0.354996 1326701109.000000 301.842627 1326701109 1/16/12 3:05 251 1
1326701169.000000 0.344313 1326701169.000000 296.874543 1326701169 1/16/12 3:06 270 0
1326701229.000000 0.333934 1326701229.000000 291.988228 1326701229 1/16/12 3:07 258 0
1326701289.000000 0.323855 1326701289.000000 287.182339 1326701289 1/16/12 3:08 260 0
1326701349.000000 0.314069 1326701349.000000 282.455550 1326701349 1/16/12 3:09 280 0
1326701409.000000 0.304569 1326701409.000000 277.806560 1326701409 1/16/12 3:10 274 0
1326701469.000000 0.295348 1326701469.000000 273.234088 1326701469 1/16/12 3:11 255 1
1326701529.000000 0.286399 1326701529.000000 268.736876 1326701529 1/16/12 3:12 260 0
1326701589.000000 0.277715 1326701589.000000 264.313684 1326701589 1/16/12 3:13 269 0
1326701649.000000 0.269290 1326701649.000000 259.963294 1326701649 1/16/12 3:14 261 0
1326701709.000000 0.261116 1326701709.000000 255.684508 1326701709 1/16/12 3:15 250 0
1326701769.000000 0.253186 1326701769.000000 251.476148 1326701769 1/16/12 3:16 234 0
1326701829.000000 0.245494 1326701829.000000 247.337053 1326701829 1/16/12 3:17 317 0
1326701889.000000 0.238033 1326701889.000000 243.266085 1326701889 1/16/12 3:18 200 0
1326701949.000000 0.230796 1326701949.000000 239.262122 1326701949 1/16/12 3:19 211 0
1326702009.000000 0.223778 1326702009.000000 235.324060 1326702009 1/16/12 3:20 261 0
1326702069.000000 0.216971 1326702069.000000 231.450816 1326702069 1/16/12 3:21 245 0
1326702129.000000 0.210370 1326702129.000000 227.641323 1326702129 1/16/12 3:22 228 0
1326702189.000000 0.203969 1326702189.000000 223.894530 1326702189 1/16/12 3:23 226 0
1326702249.000000 0.197761 1326702249.000000 220.209407 1326702249 1/16/12 3:24 209 0
1326702309.000000 0.191742 1326702309.000000 216.584938 1326702309 1/16/12 3:25 193 2
1326702369.000000 0.185905 1326702369.000000 213.020125 1326702369 1/16/12 3:26 181 1
1326702429.000000 0.180245 1326702429.000000 209.513985 1326702429 1/16/12 3:27 214 0
1326702489.000000 0.174757 1326702489.000000 206.065554 1326702489 1/16/12 3:28 250 0
1326702549.000000 0.169436 1326702549.000000 202.673882 1326702549 1/16/12 3:29 265 0
1326702609.000000 0.164276 1326702609.000000 199.338033 1326702609 1/16/12 3:30 238 0
1326702669.000000 0.159273 1326702669.000000 196.057090 1326702669 1/16/12 3:31 252 0
1326702729.000000 0.154422 1326702729.000000 192.830149 1326702729 1/16/12 3:32 295 0
1326702789.000000 0.149719 1326702789.000000 189.656320 1326702789 1/16/12 3:33 302 0
1326702849.000000 0.145159 1326702849.000000 186.534730 1326702849 1/16/12 3:34 192 0
1326702909.000000 0.140737 1326702909.000000 183.464519 1326702909 1/16/12 3:35 178 0
1326702969.000000 0.136450 1326702969.000000 180.444841 1326702969 1/16/12 3:36 154 0
1326703029.000000 0.132294 1326703029.000000 177.474865 1326703029 1/16/12 3:37 140 0
1326703089.000000 0.128264 1326703089.000000 174.553772 1326703089 1/16/12 3:38 172 1
1326703149.000000 0.124356 1326703149.000000 171.680758 1326703149 1/16/12 3:39 188 0
1326703209.000000 0.120568 1326703209.000000 168.855031 1326703209 1/16/12 3:40 175 0
1326703269.000000 0.116895 1326703269.000000 166.075813 1326703269 1/16/12 3:41 175 0
1326703329.000000 0.113334 1326703329.000000 163.342340 1326703329 1/16/12 3:42 169 0
1326703389.000000 0.109881 1326703389.000000 160.653856 1326703389 1/16/12 3:43 147 0
1326703449.000000 0.106533 1326703449.000000 158.009624 1326703449 1/16/12 3:44 167 0
1326703509.000000 0.103288 1326703509.000000 155.408913 1326703509 1/16/12 3:45 188 0
1326703569.000000 0.100141 1326703569.000000 152.851008 1326703569 1/16/12 3:46 182 0
1326703629.000000 0.097090 1326703629.000000 150.335203 1326703629 1/16/12 3:47 130 0
1326703689.000000 0.094132 1326703689.000000 147.860807 1326703689 1/16/12 3:48 122 2
1326703749.000000 0.091264 1326703749.000000 145.427138 1326703749 1/16/12 3:49 121 0
1326703809.000000 0.088484 1326703809.000000 143.033524 1326703809 1/16/12 3:50 129 0
1326703869.000000 0.085788 1326703869.000000 140.679308 1326703869 1/16/12 3:51 164 0
1326703929.000000 0.083174 1326703929.000000 138.363840 1326703929 1/16/12 3:52 171 0
1326703989.000000 0.080640 1326703989.000000 136.086483 1326703989 1/16/12 3:53 148 0
1326704049.000000 0.078183 1326704049.000000 133.846609 1326704049 1/16/12 3:54 130 0
1326704109.000000 0.075801 1326704109.000000 131.643602 1326704109 1/16/12 3:55 116 0
1326704169.000000 0.073492 1326704169.000000 129.476855 1326704169 1/16/12 3:56 116 0
1326704229.000000 0.071252 1326704229.000000 127.345770 1326704229 1/16/12 3:57 132 1
1326704289.000000 0.069082 1326704289.000000 125.249762 1326704289 1/16/12 3:58 134 1
#!/usr/bin/env Rscript
library(ggplot2)
library(gridExtra)
fitData <- read.csv(file="./data.csv", header=TRUE, sep=",")
fitData$dates <- as.POSIXct(fitData$date, format = "%m/%d/%y %H:%M")
summary(fitData)
###
p0 <- qplot(fitData$ts1, fitData$twFit, data=fitData,
, ylab = "timestamp"
, xlab="Number of Tweets/Min"
, geom="line" )
p2 <- qplot(fitData$ts1, fitData$twitter, data=fitData,
, ylab = "timestamp"
, xlab="Number of Tweets/Min" )
p1 <- qplot(fitData$ts1, fitData$ngFit, data=fitData,
, ylab = "timestamp"
, xlab="Number of Articles/Min"
, geom="line")
p3 <- qplot(fitData$ts1, fitData$newsgator, data=fitData,
, ylab = "timestamp"
, xlab="Number of Tweets/Min" )
png(filename = "./fitsraw.png", width = 640, height = 900, units = 'px')
print(
grid.arrange(p0, p1, p2, p3, ncol=1)
)
dev.off()
p5 <- qplot(fitData$dates, fitData$twitter, data=fitData
, xlab = "Jan 16, 2012 (GMT)"
, ylab="Tweets/Min"
, geom="bar"
, fill = "red"
, main = "Twitter"
, stat = "identity") +
scale_x_datetime(format="%H:%M") +
opts(legend.position = "none") +
geom_line(aes(fitData$dates, fitData$twFit), fitData, color="blue")
p7 <- qplot(fitData$dates, fitData$newsgator, data=fitData
, xlab = "Jan 16, 2012 (GMT)"
, ylab="Articles/Min"
, geom="bar"
, fill = "red"
, main = "Newsgator"
, stat = "identity") +
scale_x_datetime(format="%H:%M") +
opts(legend.position = "none") +
geom_line(aes(fitData$dates, fitData$ngFit), fitData, color="blue")
png(filename = "./pubfits.png", width = 534, height = 700, units = 'px')
print(
grid.arrange(p5, p7, ncol=1)
)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment