Question

I need to visualize events for a given month and how they change over time. I have a row for each month over several years. For example, the first row shows me activity over time for M1. I want to visualize how many of those M1_Count events changed over time (Month_Change vars). I'd like to do that for each month. I'm uncertain that this data.frame is in the appropriate format for ggplot just yet though.

       M1_Count  M2_Count M3_Count ... M1_Change M2_Change M3_Change
M1          5        0       1           2           1        0 
M2          0        2       0           0           0        1    
M3          0        0       7           0           0        4

In my head I'm visualizing a bubble chart in ggplot. Each row (month) would correspond to a row of bubbles on the plot. The first bubble on a row would indicate the initial number of events. Then there would be successive bubbles on that same row that would show the Month_Change vars for that particular month.

Is my data.frame in the best format to create this type of chart? If not, what is an appropriate format and how can I transform my data.frame accordingly?

Was it helpful?

Solution

Yes, this is possible, with base graphics or with ggplot. If you're using base graphics, the format of your data is really just personal preference. In ggplot, long form is preferred (yours is wide). The melt function in the reshape library is useful for changing the form of your data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top