Uses R to create bar plots of region server writes.
-
Save the sample data into ~/tmp/region-data.csv
-
Install R and start R console
-
Paste the R commands into R console
| Time | Region | Total Writes | New Writes | |
|---|---|---|---|---|
| 1 | Start | 15 | 15 | |
| 1 | C | 16 | 16 | |
| 1 | F | 18 | 18 | |
| 1 | J | 15 | 15 | |
| 1 | N | 10 | 10 | |
| 1 | R | 9 | 9 | |
| 1 | T | 9 | 9 | |
| 1 | W | 5 | 5 | |
| 2 | Start | 73 | 58 | |
| 2 | C | 74 | 58 | |
| 2 | F | 87 | 69 | |
| 2 | J | 90 | 75 | |
| 2 | N | 45 | 35 | |
| 2 | R | 56 | 47 | |
| 2 | T | 36 | 27 | |
| 2 | W | 24 | 19 | |
| 3 | Start | 175 | 102 | |
| 3 | C | 176 | 102 | |
| 3 | F | 198 | 111 | |
| 3 | J | 191 | 101 | |
| 3 | N | 116 | 71 | |
| 3 | R | 181 | 125 | |
| 3 | T | 97 | 61 | |
| 3 | W | 49 | 25 |
| # Paste this into R console. | |
| # Install packages once | |
| install.packages(c("reshape2","magrittr","ggplot2"), repos="http://cran.r-project.org" ) | |
| # Import symbols | |
| library(reshape2) | |
| library(magrittr) | |
| library(ggplot2) | |
| # Define input source | |
| csvfile <- '~/tmp/region-data.csv' | |
| # Graph data | |
| csvfile %>% read.csv %>% # Read CSV | |
| subset(.,select=-c(New.Writes)) %>% # Drop New Writes column | |
| dcast(.,Time~Region,value.var='Total.Writes') %>% # Long to wide | |
| melt(.,id.vars=c('Time')) %>% # Wide to long | |
| ggplot(., aes(x=Time, y=value,fill=variable)) + # Plot | |
| geom_bar(stat='identity') + | |
| scale_fill_discrete(name="Regions") + | |
| xlab('Time') + | |
| ylab('Total Writes') |