display time series data in R

[This article was first published on One Tip Per Day, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Thanks to the Revolutions blog, several things learned here:
1. R code for heat calendar
2. generate SVG from R
3. pretty-R tool

OK. Let’s explain it by plotting the fund WASCX (IVY ASSET STRATEGY FUND CLASS C) from 2009-03-14:

# source code of calendarHeat (by Paul Bleicher)
source("http://blog.revolution-computing.com/downloads/calendarHeat.R")
 
# fetch stock time series data from Yahoo finance
stock <- "WASCX"
start.date <- "2009-03-14"
end.date <- Sys.Date()
quote <- paste("http://ichart.finance.yahoo.com/table.csv?s=",
stock,
"&a=", substr(start.date,6,7),
"&b=", substr(start.date, 9, 10),
"&c=", substr(start.date, 1,4),
"&d=", substr(end.date,6,7),
"&e=", substr(end.date, 9, 10),
"&f=", substr(end.date, 1,4),
"&g=d&ignore=.csv", sep="")
stock.data <- read.csv(quote, as.is=TRUE)
 
# display in SVG format
svg("WASCX.svg",width=14,height=7)
calendarHeat(stock.data$Date, stock.data$Adj.Close,
varname="WASCX Adjusted Close")
dev.off()

To leave a comment for the author, please follow the link and comment on their blog: One Tip Per Day.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)