I am reading time series data CSV into an R data frame, using the read.csv function
I am then converting the date column (column 1) as follows:
mydata[,1] <- as.Date(mydata[,1])
I want to know how to:
- Sort the data in the data frame by date (ascending or descending)
- Once the data is sorted, I would like to use the dates as an index into the data frame, to fetch a row of data (i.e. an observation set for that date. How may I do this?
Assuming you have a time series of numbers indexed by unique dates,
read.zooin the zoo package does most of that. Read the 5 vignettes that comes with it as well as ?read.zoo and in particular thezoo-readvignette.