Lyrk
Lyrk

Reputation: 2010

Plotting hourly data

I am trying to plot a series hourly using this simple data by converting .csv data into an xts object by using these commands. It is successfully converted into a xts object but when I plot it, because there are 2 values on 31.08.2010, only one of them is shown on that day. How can I make a hourly plot instead of daily by using plot command?

Data <- structure(list(DATE = c("17.08.2010 17:00", "24.08.2010 11:00",
  "31.08.2010 16:00", "31.08.2010 17:00"), Return = c(0.00025, -0.007498,
  -0.009066, 0.000889)), .Names = c("DATE", "Return"), class = "data.frame",
  row.names = c(NA, -4L))
myxts <- xts(Data$Return, as.POSIXct(Data$DATE, format="%d.%m.%Y %H:%M"))
plot(myxts)

Upvotes: 2

Views: 541

Answers (1)

Joshua Ulrich
Joshua Ulrich

Reputation: 176728

Both points on 31.08.2010 are shown. It's just hard to see on the line plot because they're only 1 hour apart, and the other points are >24 hours apart. You can see they're both there if you use type="p".

plot(myxts, type="p")

xts plot with type="p"

Upvotes: 3

Related Questions