[R-SIG-Finance] Quantmod
Joshua Ulrich
josh.m.ulrich at gmail.com
Sat Aug 21 14:34:14 CEST 2010
getSymbols() returns an xts object (which is a subclass of zoo) by
default. The dates in xts/zoo objects are stored in an "index"
attribute that is unique to xts/zoo objects, so write.table() doesn't
know to write this attribute to the file.
So you need to:
1) Give write.table() the rownames to use via:
write.table(IBM, file = "ibm-data.txt", row.names=index(IBM))
2) Or (my preference) use write.zoo():
write.zoo(IBM, file = "ibm-data.txt")
HTH,
--
Joshua Ulrich
FOSS Trading: www.fosstrading.com
On Sat, Aug 21, 2010 at 5:58 AM, Werner Erselina <w.erselina at gmail.com> wrote:
> Hi fellow R users,
>
> As a new user to r and quantmod i have the following problem. Using quantmod
> for retrieving data from yahoo or google i am stuck in writing this data to
> a text file.
>
>> getSymbols("IBM")
> [1] "IBM"
>> write.table(IBM, file = "ibm-data.txt")
>
> The text file created this way does not contain the date information.
>
> So how could i best write quantmod data to a text file?
>
> greetings,
>
> Werner
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>
More information about the R-SIG-Finance
mailing list