[R] Getting started,

Gabor Grothendieck ggrothendieck at gmail.com
Thu Mar 26 12:45:23 CET 2009

Try this:


my.url <- "http://www.federalreserve.gov/releases/h15/data/Business_day/H15_ED_M1.txt"
z <- read.zoo(my.url, skip = 8, header = TRUE, sep = ",", na.strings = "ND",
	strip.white = TRUE, FUN = as.chron)

# or to plot with NAs interpolated

See the three zoo vignettes:
vignette(package = "zoo")
# etc.

and for more on dates see R News 4/1.

On Thu, Mar 26, 2009 at 6:58 AM, gug <guygreen at netvigator.com> wrote:
> Hello,
> First of all, I'm new to R and I don't have anyone who already knows the
> language to ask for tips, so please excuse my ignorance.
> I'm trying to download data direct from the Federal Reserve statistics
> website and graph it, using the following:
>        #This downloads the data from the Fed website
> download.file("http://www.federalreserve.gov/releases/h15/data/Business_day/H15_ED_M1.txt","Eurodollar_deposits1M.dat")
>        #This reads that data into a table
> data_download=read.table("Eurodollar_deposits1M.dat",skip=8,sep=",",head=T)
>        #This is attempting to get R to read the date column, which is in
> "mm/dd/yyyy" format
>        #I have restricted it to the first 50 data points (to keep it simple)
> date_vec = as.Date(data_download[1:50,1],"%m/%d/%y")
>        #This reads the values again for just the first 50 data points
> eurodollar_vec = data_download[1:50,2]
>        #This plots the date and data values.
> plot(date_vec,eurodollar_vec)
> A few issues with the output from this:
> 1) The date_vec data ends up looking like this "2019-01-04" - for some
> reason all year 2019, irrespective of the actual year (e.g. 1971, 1972).
> Any suggestions as to where I am going wrong?
> 2) The chart ends up as a scatter diagram, not surprisingly.  I initially
> tried to use the ts.plot() function but when I did, I found that it doesn't
> use the date column in the data as the x axis.  Is there a way of creating a
> time series that uses the date column, or alternatively, how would I turn
> these two columns (date & value) into a line graph?
> 3) The y-axis output should be from about 4.5 to about 8.5, but the y-axis
> shows as being about 430-670.  There also seems to be a line of points
> across the top which are all of the same value - as though anything above
> about 670 gets charted as 670.
> I'm sorry for this being a "what am I doing wrong" post, but I have looked
> through the manuals without success, and I am new enough to R that I don't
> have a feel for ways round these sorts of problems.  Any suggestions would
> be greatly appreciated.  Thanks.
> --
> View this message in context: http://www.nabble.com/Getting-started%2C-tp22719735p22719735.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list