Reputation: 1713
I have this huge data frame that has servernames, Date, CPU, memory as the headers. There are multiple servers names. I would like to be able to select certain server name order by the date column and create time serious graphs
this is a small subset of the data frame:
Hostname Date 5 60 61 CPUAVG CPUAVG+Sev CPUMaximum MemoryAVG
1 server1 2012-01-29 01:00:00 23.79 NA NA 2.33 0.72 2.33 23.76
2 server1 2012-01-29 02:00:00 23.91 NA NA 2.86 2.38 2.86 23.82
3 server1 2012-01-29 03:00:00 25.65 NA NA 6.25 9.59 6.25 24.85
4 server2 2012-01-29 04:00:00 26.30 NA NA 18.41 31.09 18.41 25.87
5 server3 2012-01-29 05:00:00 24.33 NA NA 1.92 0.42 1.92 24.24
6 server3 2012-01-29 06:00:00 24.40 NA NA 2.65 1.79 2.65 24.31
Upvotes: 0
Views: 13979
Reputation: 18487
#convert Date to a date field (if needed)
library(lubridate)
servers$Date <- ymd_hms(servers$Date)
#select the servers you need
SelectedServers <- subset(servers, Hostname %in% c("server1", "server3"))
library(ggplot2)
#no need for sorting with ggplot2
ggplot(SelectedServers, aes(x = Date, y = CPUAVG, colour = Hostname)) + geom_line()
ggplot(SelectedServers, aes(x = Date, y = CPUAVG)) + geom_line() + facet_wrap(~Hostname)
Upvotes: 2
Reputation: 17527
Checkout the 'subset' command.
thisServer <- subset (servers, Hostname="server1")
Then to order the rows
thisServerSorted <- thisServer[order(thisServer$Date),]
Then you can plot from there.
Upvotes: 3