+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 16 to 30 of 52

Thread: [R Graphics] Beautiful graphics thread

  1. #16
    Cookie Scientist
    Points: 6,080, Level: 50
    Level completed: 65%, Points required for next Level: 70
    Jake's Avatar
    Location
    Boulder, CO
    Posts
    814
    Thanks
    18
    Thanked 320 Times in 245 Posts

    Re: [R Graphics] Beautiful graphics thread



    Looks like all the "Others" prefer to talk to me
    “In God we trust. All others must bring data.”
    ~W. Edwards Deming

  2. #17
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread

    I wanted to point out the talk stats library I bundled up using Dason and bryangoodrich's collective genius that downloads the chat box.

    To download package:
    Code: 
    # install.packages("devtools")
    library(devtools)
    install_github("talkstats", "trinker")
    To download chats (I think it tries to get your user name password and store it the first time you use it but you can manually add to arguments each time):
    Code: 
    library(talkstats)
    x <- ts_chatbox(splitDate = FALSE)
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  3. #18
    Multicollinearity hater
    Points: 6,538, Level: 52
    Level completed: 94%, Points required for next Level: 12
    victorxstc's Avatar
    Posts
    741
    Thanks
    170
    Thanked 181 Times in 163 Posts

    Re: [R Graphics] Beautiful graphics thread

    Quote Originally Posted by SiBorg View Post
    Also, from the chatbox statistics, I think we can say that Greta and Victor are very likely to be starting up a relationship (p<0.0001).
    lol

    As another suggestion, maybe we might update the status of the chats in future time spans and make it a repeated-measures analysis!

  4. #19
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread

    We were looking at association of chatters. I'm working on an average distance measure function in R that goes with the visual representation as a gantt plot as seen below.

    The code is pretty simple but relies on the qdap package that you'd have to download from my github. Also you'll need the talkstats package from there as well:

    Getting qdap and talkstats
    Code: 
    # install.packages("devtools")
    library(devtools)
    install_github("talkstats", "trinker")
    nstall_github("qdap", "trinker")
    Making gantt plots
    Code: 
    library(qdap); library(talkstats)
    
    dat <- ts_chatbox()
    
    #plot 1 colored
    x <- with(dat, gantt_plot(dialogue, person))
    
    #plot 2 black
    x + scale_color_manual(values=rep("black", length(levels(dat$person))))
    #or
    with(dat, gantt_plot(dialogue, person, bar.color="black"))
    
    #plot 3 faceted
    with(dat, gantt_plot(dialogue, person, date, space = "free"))
    To get a pdf of the graphics together -click here-

    Plot 1

    Plot2

    Plot2
    Too big to display. -click here- instead.

    The level of detail in the pdf is well worth it. png tends to lose some smaller time durations.

    The next step for this is to finish working on the distance function by first properly using the math annotation to describe what's going on and also use with outer and Vectorize to produce a distance matrix of average distances between users. If anyone wants to help here's that thread (LINK).
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  5. #20
    RotParaTon
    Points: 47,169, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,199
    Thanks
    212
    Thanked 1,642 Times in 1,403 Posts

    Re: [R Graphics] Beautiful graphics thread

    Would you mind explaining those plots?
    "His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich

  6. #21
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread

    My apologies I thought they were self explanatory probably because I've been working with them so much lately. I was hoping they were because that's the mark of a good plot. Think of the y axis as time (unit of measure though is words). Where you have a color strip you were conversing in the chat box.

    In the unfaceted plots we have time (days) as one big continuum from left to right. In the faceted I broke up the days. I could have gotten fancier with plotting the background colors by day but was lazy. To some extent then we can assume that people clustered in close proximity to each other were more conversant with on another. This distance measure I'm working on may capture this even better.

    EDIT: I just realized that the xlab is set to a funky default. I changed that behavior but don't feel like fixing the graphics (lazy).
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  7. #22
    RotParaTon
    Points: 47,169, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,199
    Thanks
    212
    Thanked 1,642 Times in 1,403 Posts

    Re: [R Graphics] Beautiful graphics thread

    Can you explain the x-axis a little more? I don't know what the units of measurement are. And in the faceted plots I would have thought it was just a plot essentially of when we were chatting over time but all of the plots start at the left and most don't take up the full plotting region - what causes that?

    Edit: I think I understand it now but I'd still like to hear your explanation. I was confused before because you said the y-axis was words but that doesn't make sense.
    "His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich

  8. #23
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread

    Yeah the x axis is time but the unit of measure is actually words. So time is measured in words. All days start with 0 words. I suppose I have functions that could plot it in time but I was looking to demonstrate something easier. The restriction ("all of the plots start at the left and most don't take up the full plotting region") on the scales is that it is unfair (IMO) to compare facets when scales are allowed to be free. I may relax this in the future though.

    I'm currently working on some functions to deal with time measures rather than words as the units but didn't forsee this until some of my recent work as an RA, so I didn't include this functionality in qdap initially.
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  9. #24
    RotParaTon
    Points: 47,169, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardCommunity AwardMaster TaggerFrequent Poster
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,199
    Thanks
    212
    Thanked 1,642 Times in 1,403 Posts

    Re: [R Graphics] Beautiful graphics thread

    No - it's fine that they don't take up the full plotting region. It was just that my intuition was that the x-axis was time and it didn't logically make sense the way the plots were laid out... which is why I was asking for clarification. But I think I get it now.
    "His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich

  10. #25
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread

    It didn't help that the default for this was duration.default. An oversight. If you try it now it will say duration (words).
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  11. #26
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread

    Dason challenged the scales free idea and I decided it shouldn't be up to me if you use it or not. I plotted three different versions playing with scales and colors. Click here to see:

    https://dl.dropbox.com/u/61803503/by_date4.pdf

    Code:
    Code: 
    library(qdap); library(talkstats)
    
    dat <- ts_chatbox()
    with(dat, gantt_plot(dialogue, person, bar.color="black"))
    with(dat, gantt_plot(dialogue, person, date, ncol = 3, scale = "free_x"))
    with(dat, gantt_plot(dialogue, person, date, ncol = 3, bar.color="black"))
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  12. The Following User Says Thank You to trinker For This Useful Post:

    vinux (10-25-2012)

  13. #27
    Bhoot
    Points: 1,434, Level: 21
    Level completed: 34%, Points required for next Level: 66

    Posts
    1,759
    Thanks
    40
    Thanked 128 Times in 107 Posts

    Re: [R Graphics] Beautiful graphics thread

    I liked the above graph. This is more comprehensible than your first graph.
    In the long run, we're all dead.

  14. The Following User Says Thank You to vinux For This Useful Post:

    trinker (10-25-2012)

  15. #28
    Probably A Mammal
    Points: 14,712, Level: 78
    Level completed: 66%, Points required for next Level: 138
    bryangoodrich's Avatar
    Location
    Sacramento, California, United States
    Posts
    1,963
    Thanks
    223
    Thanked 422 Times in 389 Posts

    Re: [R Graphics] Beautiful graphics thread

    One of the things in the energy industry that is important is looking at smart meter data (meters with wifi giving interval data--15, 60 min data maybe). For instance, we want to be able to tease out from data certain phenomena happening at regular intervals. For instance, one contract's algorithms could take a year's worth of data for a household and find their baseline by looking at the hourly data.

    I bring that up because I looked at that last graph and it's entirely incomprehensible looking at daily graphs what the outcome is over all those days. For instance, when do I tend to talk the most? I'm thinking you could generate a single graph for each chatter that is sort of like a heat map where it's brightest when they talk the most and cold where they're most absent. Make sense? Implementing it, not so easy lol

    The first plot here sort of does that but it has a larger wave or whatever for when someone talks the most on a given day. I think the idea is to aggregate that information over multiple days at a given time location. That way, you end up with a composite or aggregate time value, but that plot is actually just as informative as the heat map idea I had. In fact, it visually does a good job at showing you where someone is very active, especially if it's with respect to other chatters.

  16. #29
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread

    @BG I think that wouldn't be useful for what's attempting to be shown, that being relationships. Time was pretty well shown already by Vinux. Secondly, the unit I used is words so you couldn't really tell when you talk. I didn't use times. The gantt is better in this case for relationships which is what we're after in that you can see clusters.

    Incomprehensible means that something's not comprehend-able. That really is not an accurate assessment. Depending on what you're attempting to show will depend on what graphic you use. If you're looking for when you're most active then a line graph of hourly intervals would be better or perhaps a heat map as you suggest but I think the line graph would be better suited. But this idea would convey nothing about the relationship between chatters. One more thing that throws a monkey wrench into time is that there's a universal time zone being used. So when it say's I'm really active at 6 am, that's not true. For me It's probably 12 am but time is a relative concept with world chatters.

    As far as implementing the heat map it would be pretty easy by creating a new variable that turns times into hours and then using geom_tile. I've done as a calendar heat map with relative ease.
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  17. #30
    ggplot2orBust
    Points: 25,031, Level: 95
    Level completed: 69%, Points required for next Level: 319
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    3,220
    Thanks
    920
    Thanked 563 Times in 510 Posts

    Re: [R Graphics] Beautiful graphics thread


    Here's the line and heat plot:

    Code: 
    library(ggplot2); library(talkstats); library(plyr); library(reshape2)
    dat <- ts_chatbox()
    dat$hour <- sapply(strsplit(as.character(dat$time), ":"), 
        function(x) x[c(T, F, F)])
    dat2 <- data.frame(with(dat, table(person, hour)))
    
    
    #line plot
    ggplot(dat2, aes(hour, Freq, group=person)) + 
        geom_line(aes(colour=person), size=1) +
        facet_wrap(~person, ncol=3)+
        theme(axis.text.x=element_text(angle=270), legend.position="none")
    
    #heat plot
    x2 <- melt(dat2)
    x2 <- ddply(x2, .(person), transform,
       rescale = rescale(value))
    
    ggplot(x2, aes(person, hour, group=person)) + geom_tile(aes(fill = rescale),
        colour = "white") + scale_fill_gradient(low = "white",
        high = "red") + theme_grey() + labs(x = "",
        y = "") + scale_x_discrete(expand = c(0, 0)) +
        scale_y_discrete(expand = c(0, 0)) + theme(legend.position = "none",
        axis.ticks = element_blank(), axis.text.x = element_text(angle = -90, 
            hjust = 0, colour = "grey50"))
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats