TutorTeddy.com, Tutoring, Dallas, TX
Like us for free help*

Getting the Data from the Web Using R


Ask any Statistics/Probability/Math Question

R package 9 includes the function get.hist.quote() that can be used to download the quotes into a zoo object. The following is an example of the use of this function to get the quotes:



R Package 9

As the function get.hist.quote() returns an object of class zoo , we have again used the function as.xts() to compel it to xts. We should remark that if you issue these commands, you will get more data than what is provided with the object in the book package. You may wonder why we did not load the package zoo with a call to the library() function. The reason is that this was already done when



Where"2009-09-15"is the last day with quotes in the package GSPC object. Another way of obtaining quotes data from the Web (but not the only, as we will see later), is to use the function get Symbols () from package quantmod (Ryan, 2009). Again this is an extra package that you should install before using it. It provides several facilities related to financial data analysis that we will use throughout this chapter. Function get Symbols()In conjunction with other functions of this package provide a rather simple but powerful way of getting quotes data from deferent data sources.


We will now see some examples of its use:



R session with the set Symbol Lookup() function

With the framework provided by package quant mod you may actually have several symbols with different associated sources of data, each with its own parameters. All these settings can be specified at the start of your R session with the set Symbol Lookup() function, as you may see in the following example:



In this code we have specified several settings for getting the quotes from the Web of two different symbols for IBM -This is done through function


Set Symbol Lookup(), which ensures any subsequent use of the get Symbols()function in the current R session with the identifiers specified in the call, will use the settings we want. In this context, the second statement will fetch the quotes of the two symbols using the information we have specified. Functions save Symbol Lookup() and load Symbol Lookup() can be used to save and load these settings across different R sessions. Check the help of these functions for further examples and more thorough explanations of the workings behind these handy functions


Financial Data Analysis

TutorTeddy.com & Boston Predictive Analytics

[ Email your Statistics or Math problems to tutor@aafter.com (camera phone photos are OK) ]


Boston Office (Near MIT/Kendall 'T'):
Cambridge Innovation Center,
One Broadway, 14th Floor,
Cambridge, MA 02142,
Phone: 617-395-8864


Dallas Office (Near Galleria):
15950 Dallas Parkway,
Suite 400,
Dallas, TX 75248,
Phone: 866-930-6363

Copyright 2011 tutorteddy.com. All Rights Reserved. | By using our site, you agree to our TOS.