A.J
A.J

Reputation: 1180

Plotting dataframe in r

I have the following dataframe (1:10):

   Date Avg.Join.Delay Min.Join.Dely Max.Join.Dely    ACCOUNT STB_TYPE  MARKET
1  6/5/2015      199.20000            51           396 2063207586  IPH8010 Seattle
2  6/5/2015       77.68750            50           145 2063207586  IPW8000 Seattle
3  6/5/2015       80.00000            78            81 2063221752  IPW8000 Seattle
4  6/5/2015       72.25000            52            81 2063231994  IPW8000 Seattle

What I am trying to do is to plot a graph of the Average delay with regard to its Min and Max. I want to see the correlation of these three attributes in a visual way but I can't figure out a way doing so. Below is a reproducible example:

df <- data.frame(Date= c('6/5', '6/6', '6/7'), 
                  Avg = c(600, 500, 400),
                  Min = c(25, 85, 40),
                  Max = c(65, 28, 39),
                  Account = c(504,316,920),
                  Type = c('x','y','z'),
                  Market = c('a','b','c'))

Upvotes: 1

Views: 115

Answers (1)

C8H10N4O2
C8H10N4O2

Reputation: 18995

This seems a good use of geom_pointrange(), but it will make no sense for your example, because your Avg is higher than your Max, and on 6/7 your Min is higher than your Max.

library(ggplot2)
ggplot(df, aes(x=Date, y=Avg)) + 
  geom_pointrange(aes(ymin=Min, ymax=Max))

enter image description here

Upvotes: 3

Related Questions