Created
July 29, 2015 17:31
-
-
Save geojackass/bf203d3b9f5ccbcfc1b1 to your computer and use it in GitHub Desktop.
timeseries data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data <- read.csv('stock_px.csv') | |
#setup libraries | |
options(CRAN="http://cran.ism.ac.jp/") | |
options(repos="http://cran.ism.ac.jp/") | |
install.packages('ggplot2') | |
install.package('reshape2') | |
library(ggplot2) | |
library(reshape2) | |
#head(data) | |
colnames(data)[1] <- "dtm" | |
data.bind <- cbind(1:nrow(data), data) | |
head(data.bind) | |
colnames(data.bind)[1] <- "id" | |
data.melted <- melt(data.bind, id.var=c('id', 'dtm')) | |
head(data.melted) | |
g <- ggplot(data.melted, aes(x=as.Date(data.melted$dtm), y=data.melted$value, colour=data.melted$variable)) | |
g <- g + geom_line(size=1) | |
g <- g + xlab("Date") + ylab("stock") + ggtitle("stock-prices") + labs(colour="company") | |
plot(g) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment