Reputation: 1713
This group has been very helpful, I really appreciate all the help. You guys are awesome. I searched but could not find an answer. I have a data frame which incluces 1st column server names and others have different metrics. I would like to be able to use ggplot2 to go though the data frame and create charts based on unique rows (servernames). How can I do this given a large data set.
Here is a sample data set:
Hostname Date CPU Mem cpu avg io mem
host1 2012-01-01 01:00:00 27.24 2.33 0.47 2.33 27.20
host1 2012-01-01 02:00:00 28.00 22.38 36.50 22.38 27.49
host2 2012-01-01 03:00:00 29.31 7.58 12.23 7.58 28.56
host2 2012-01-01 04:00:00 29.37 2.44 0.35 2.44 29.30
host3 2012-01-01 05:00:00 29.07 2.86 1.04 2.86 28.02
host3 2012-01-01 06:00:00 28.05 2.74 0.67 2.74 27.96
> str(yy)
List of 10
$ Hostname : Factor w/ 37 levels "host1",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Date : POSIXct[1:26088], format: "2012-01-01 01:00:00" "2012-01-01
02:00:00" "2012-01-01 03:00:00" "2012-01-01 04:00:00" ...
$ variable : chr [1:26088] "1:00:00" "2:00:00" "3:00:00" "4:00:00" ...
$ 5 : num [1:26088] 27.2 28 29.3 29.4 29.1 ...
$ 60 : num [1:26088] NA NA NA NA NA NA NA NA NA NA ...
$ 61 : num [1:26088] NA NA NA NA NA NA NA NA NA NA ...
$ CPUAVG : num [1:26088] 2.33 22.38 7.58 2.44 2.86 ...
$ CPUAVG+Sev: num [1:26088] 0.47 36.5 12.23 0.35 1.04 ...
$ CPUMaximum: num [1:26088] 2.33 22.38 7.58 2.44 2.86 ...
$ MemoryAVG : num [1:26088] 27.2 27.5 28.6 29.3 28 ...
- attr(*, "row.names")= int [1:26088] 1 2 3 4 5 6 7 8 9 10 ...
- attr(*, "idvars")= chr [1:3] "Hostname" "Date" "variable"
- attr(*, "rdimnames")=List of 2
..$ :'data.frame': 26088 obs. of 3 variables:
.. ..$ Hostname: Factor w/ 37 levels "host1",..: 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ Date : Factor w/ 31 levels "01/01/2012","01/02/2012",..: 1 1 1 1 1 1 1 1
1 1 ...
.. ..$ variable: Factor w/ 24 levels "Hour1","Hour2",..: 1 2 3 4 5 6 7 8 9 10 ...
..$ :'data.frame': 7 obs. of 1 variable:
.. ..$ MetricType: Factor w/ 7 levels "5","60","61",..: 1 2 3 4 5 6 7
Upvotes: 1
Views: 135
Reputation: 44648
Sounds like a facetting question to me. Here's an example. Updated with your data
# Dummy data
x <- data.frame(
hostname=rep(paste("host",1:3,sep=""),1000),
date=as.Date(1:1000,origin="2005-01-01"),
CPUMEM=rnorm(1000)+20,
CPU=rnorm(1000)+10,
avg=rnorm(1000)+10,
io=rnorm(1000)+5,
mem=rnorm(1000)+27)
x <- melt(x, c("hostname","date"))
ggplot(x, aes(date,value, color=variable)) + geom_line() + facet_grid(~hostname)
Upvotes: 1