I’m trying to write a function that will load some xts data into R, and sort them by the date/time I specify. Maybe I’m trying a too simplistic method, but here is my code:
load.data <- function (x, time1, time2) #x is going to be the actual file name
{
vector = get(load("C:/Users/username/Desktop/x"))
sortvector = vector['time1/time2/']
return (sortvector)
}
And when I execute it, I get the message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file 'C:/Users/username/Desktop/x', probable reason 'No such file or directory'
So, how can I make it so that my function will actually search for the file name, rather than actual generic ‘x’? I hope I was clear, and I would certainly appreciate any help greatly.
Use
pasteorpaste0Also, look at
?FinancialInstrument:::saveSymbols.daysand?FinancialInstrument:::getSymbols.FI, or look at the code for those functions for examples of saving and loadingxtsobjectsEdit
Here’s an example