Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rtanglao/1061969 to your computer and use it in GitHub Desktop.
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
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)
dfrm_long <- melt(dfrm,id="month")
ggplot(data=dfrm_long,aes(x=month,y=value, colour=variable)) +
geom_line() + geom_point() + theme_bw()
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
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")
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"))
@rtanglao
Copy link
Author

rtanglao commented Jul 3, 2011

here is the resulting graph from "happy - sad.r":
Get Satisfaction Thunderbird emotitags - happy-sad August 2009 to May 2011

@rtanglao
Copy link
Author

rtanglao commented Jul 3, 2011

Here is the resulting graph from MissingHappySadSillyIndifferent.r
Get Satisfaction Thunderbird Emotitags Aug 2009 - May 2011

@rtanglao
Copy link
Author

rtanglao commented Jul 3, 2011

Here is the resulting graph from BetterMissingHappySadSillyIndifferent.r :
BETTER version of Get Satisfaction Thunderbird Reply Emotitags Aug 2009 - May 2011

@rtanglao
Copy link
Author

rtanglao commented Jul 4, 2011

should use as.Date instead of strptime:
http://www.ats.ucla.edu/stat/r/faq/string_dates.htm

@rtanglao
Copy link
Author

rtanglao commented Jul 4, 2011

dates <- as.Date(strDates, "%m/%d/%Y"):

i.e.:

dateVector <- as.Date(paste(as.character(tbl$yyyymm),"01",sep=""),format="%Y%m%d")

@rtanglao
Copy link
Author

rtanglao commented Jul 4, 2011

new_tbl < - tbl
new_tbl$yyyymm <- as.Date(paste(as.character(tbl$yyyymm),"01",sep=""),format="%Y%m%d")

@rtanglao
Copy link
Author

rtanglao commented Jul 4, 2011

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