Created
July 3, 2011 05:06
-
-
Save rtanglao/1061969 to your computer and use it in GitHub Desktop.
R Lang Yak Shaving to convert Thunderbird Get Satisfaction "emotitag" csv data into a graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tbl <- read.csv("/Users/rolandtanglao/Documents/MOZILLA_MESSAGING/MOMOGS/momogs/getEmotitag.200981.2011531.csv") | |
| tbl$yyyymm <- as.Date(paste(as.character(tbl$yyyymm),"01",sep=""),format="%Y%m%d") | |
| dfrm_long <- melt(tbl,id="yyyymm") | |
| myplot <- ggplot(data=dfrm_long,aes(x=yyyymm,y=value, colour=variable)) + geom_line() + geom_point() + theme_bw() | |
| ggsave(myplot,filename="blah.png",scale=1.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dfrm_long <- melt(dfrm,id="month") | |
| ggplot(data=dfrm_long,aes(x=month,y=value, colour=variable)) + | |
| geom_line() + geom_point() + theme_bw() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| yyyymm | happy | sad | silly | indifferent | emotitagMissing | |
|---|---|---|---|---|---|---|
| 200908 | 168 | 67 | 7 | 10 | 210 | |
| 200909 | 334 | 75 | 9 | 11 | 316 | |
| 200910 | 284 | 71 | 15 | 28 | 406 | |
| 200911 | 363 | 193 | 17 | 208 | 707 | |
| 200912 | 747 | 785 | 80 | 161 | 2950 | |
| 201001 | 709 | 947 | 94 | 162 | 3958 | |
| 201002 | 586 | 795 | 73 | 140 | 3591 | |
| 201003 | 626 | 669 | 68 | 135 | 2437 | |
| 201004 | 393 | 581 | 60 | 91 | 2561 | |
| 201005 | 316 | 531 | 53 | 90 | 2501 | |
| 201006 | 517 | 543 | 44 | 99 | 2879 | |
| 201007 | 422 | 622 | 69 | 100 | 3595 | |
| 201008 | 686 | 882 | 82 | 169 | 5571 | |
| 201009 | 649 | 981 | 81 | 147 | 4306 | |
| 201010 | 481 | 713 | 60 | 125 | 3722 | |
| 201011 | 430 | 581 | 45 | 75 | 3069 | |
| 201012 | 334 | 476 | 46 | 81 | 2732 | |
| 201101 | 353 | 436 | 52 | 86 | 3843 | |
| 201102 | 330 | 381 | 44 | 77 | 3529 | |
| 201103 | 308 | 351 | 56 | 56 | 2763 | |
| 201104 | 274 | 280 | 33 | 61 | 2536 | |
| 201105 | 92 | 99 | 23 | 20 | 1471 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tbl <- read.csv("/Users/rolandtanglao/Documents/MOZILLA_MESSAGING/MOMOGS/momogs/getEmotitag.200981.2011531.csv") | |
| yyyymm = tbl$yyyymm | |
| ystr <- as.character(yyyymm) | |
| ystr <- paste(ystr,"01",sep="") | |
| y <- strptime(ystr,format="%Y%m%d") | |
| dfrm <- data.frame(month=y,happy=tbl$happy,sad=tbl$sad,silly=tbl$silly,indifferent=tbl$indifferent,missing=tbl$emotitagMissing) | |
| qplot(month,happy-sad,data=dfrm,geom= "line") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ggplot(dfrm,aes(month))+ | |
| geom_line(aes(y = missing, color="missing"))+ | |
| geom_line(aes(y = happy, colour="happy"))+ | |
| geom_line(aes(y = sad, colour="sad"))+ | |
| geom_line(aes(y = silly, colour="silly"))+ | |
| geom_line(aes(y = indifferent, colour="indifferent")) |
Author
Author
new_tbl < - tbl
new_tbl$yyyymm <- as.Date(paste(as.character(tbl$yyyymm),"01",sep=""),format="%Y%m%d")
Author
tbl <- read.csv("/Users/rolandtanglao/Documents/MOZILLA_MESSAGING/MOMOGS/momogs/getEmotitag.200981.2011531.csv")
tbl$yyyymm <- as.Date(paste(as.character(tbl$yyyymm),"01",sep=""),format="%Y%m%d")
dfrm_long <- melt(tbl,id="yyyymm")
ggplot(data=dfrm_long,aes(x=yyyymm,y=value, colour=variable)) + geom_line() + geom_point() + theme_bw()
NOTE: the above is documented in BestWayToGraphACSVFileWithYYYYMMData.R
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i.e.: