How to plot LTP vs. time from data available in a matrix in the form of Date, time, LTP

67 Views Asked by At

I have data in 3 columns:(as shown below

  • Date Time LTP
  • 20180102 09:16 1800
  • ... ... ... I wanna plot it in R so that I get time on the x-axis and LTP on the y-axis. Since there are around 360 rows every day (every minute LTP changes), the x variable shall be date:time I am new to R and I need help in this. Thanks in anticipation
1

There are 1 best solutions below

3
On BEST ANSWER

Try this:

library(zoo)
z <- read.zoo("myfile.dat", header = TRUE, index = 1:2, format = "%Y%m%d %H:%M", tz = "")

# classic graphics
plot(z)

# ggplot2 graphics
autoplot(z)

Note

To generate a file for the sample data provided in the question try this; however, with only one point you won't see anything on a line graph.

cat("Date Time LTP\n20180102 09:16 1800", file = "myfile.dat")