Plotting time series with R

I'm using R and I've to plot 50 point. My input data are something like these:

Day             Pressure
20/01/2013 13:30:00     980
20/01/2013 20:30:00     978
21/01/2013 13:30:00     985
21/01/2013 20:30:00     991

I've some problems because I can't find the right command to plot the Day vs the Pressure.

Answers


This might help you plot the data using ggplot2.

The data I used was as follows:

Day             Pressure
20/01/2013 13:30:00 980
20/01/2013 20:30:00 978
21/01/2013 13:30:00 985
21/01/2013 20:30:00 991

The code is as follows:

library(ggplot2)
data2 <- read.csv("Stack Overflow/timeseries.csv")
data2
data2$Day <- strptime(data2$Day, format="%d/%m/%Y %H:%M:%S")
ggplot(data2, aes(x=Day, y=Pressure))+geom_point()+xlab("Date")

Hope it helps.

Output

If you want to use base plot then use the following:

plot(data2$Day,data2$Pressure, xlab="Date",ylab="Pressure")

Using the zoo package read the data into z and plot it:

Lines <- "Day             Pressure
20/01/2013 13:30:00 980
20/01/2013 20:30:00 978
21/01/2013 13:30:00 985
21/01/2013 20:30:00 991
"

library(zoo)
z <- read.zoo(text = Lines, skip = 1, index = 1:2, tz = "", format = "%d/%m/%Y %H:%M:%S")
plot(z)


Need Your Help

AWK: find out if running on windows

windows awk

How can i find out whether i am on Windows or not?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.