Skip to content
Prev 42373 / 398506 Next

Importing Excel/Openoffice Dates into R

/"I am puzzled: `csv' means `comma-separated values' and those files 
have no
commas in them. You could use"
/
Yes sorry about that. The data posted was from the original csv files. I 
just copy and pasted a subsection from the spreadsheet as an example.

/"(AB <- merge(A, B, by="row.names", all=T))"/

I did a "?merge" in R, and it said that this was for two dataframes. I 
would like to find a more general solution for a large number of 
variables with different dates. Financial time series dates are often 
dictated by the holidays of the respective stock/futures exchanges. This 
is a common problem I face.

/"Date <- as.POSIXct(strptime(as.character(AB$Row.names), "%m/%d/%Y"))
row.names(AB) <- Date
AB <- AB[sort.list(Date),-1]
AB"

/That looks like something I could use.

/"Second, as ts.union is not part of tseries, and is for regular time 
series. I don't see how you hoped to use it."
/
I was inspired by the "get.hist.quote" function. From the help file for 
"get.hist.quote"


x <- get.hist.quote(instrument = "^spc", start = "1998-01-01",
quote = "Close")
plot(x)

x <- get.hist.quote(instrument = "ibm", quote = c("Cl", "Vol"))
plot(x, main = "International Business Machines Corp")

spc <- get.hist.quote(instrument = "^spc", start = "1998-01-01")
ibm <- get.hist.quote(instrument = "ibm", start = "1998-01-01")
x <- na.remove(ts.union(spc, ibm))
plot(x, main = "IBM vs S&P 500")


This example, downloads the data from yahoo, lines up the dates, and 
removes any NAs. I would like to be able to do the same for data that I 
have downloaded in my excel from a Reuters or Bloomberg terminal. I will 
play around further with what you have suggested later on tonight, and 
see if I can post back a solution. I'm in Singapore and at the end of 
the working day.

Thanks for your help.

Ashley
Prof Brian Ripley wrote: