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
library(XML) | |
theurl <- "http://www.fundserv.com/services/code-lists.php?status_type=1&file_type=d" | |
dealer.codes <- readHTMLTable(theurl) | |
n.rows <- unlist(lapply(dealer.codes, function(t) dim(t)[1])) | |
dealer.codes <- dealer.codes[[which.max(n.rows)]] |
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
system.time(for(x in 1:10000) {print("Hello world")}) ## 0.54 | |
system.time(print(rep("Hello world",10000))) ## 0.12 |
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
x <- rnorm(100)*20 | |
y <- rnorm(100)*40 | |
plot(1:100, x, type="l", col="blue", xlab="X axis label", ylab="Left legend") | |
par(new=TRUE) | |
plot(1:100, y, type="l", ann=FALSE, yaxt="n") | |
axis(4) | |
legend(x="topleft", bty="n", lty=c(1,1), col=c("blue","black"), legend=c("Left", "Right")) |
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
x <- structure(list(date = structure(c(14613, 14614, 14615, 14616, | |
14617, 14620, 14621, 14622, 14623, 14624, 14627, 14628, 14629, | |
14630, 14631, 14634, 14635, 14636, 14637, 14638, 14641, 14642, | |
14643, 14644, 14645, 14648, 14649, 14650, 14651, 14652, 14655, | |
14656, 14657, 14658, 14659, 14662, 14663, 14664, 14665, 14666, | |
14669, 14670, 14671, 14672, 14673, 14676, 14677, 14678, 14679, | |
14680, 14683, 14684, 14685, 14686, 14687, 14690, 14691, 14692, | |
14693, 14694, 14697, 14698, 14699, 14700, 14701, 14704, 14705, | |
14706, 14707, 14708, 14711, 14712, 14713, 14714, 14715, 14718, | |
14719, 14720, 14721, 14722, 14725, 14726, 14727, 14728, 14729, |
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
require("quantmod") | |
getSymbols("^GSPC;^VIX") | |
VIX <- as.data.frame(unlist(VIX)) | |
GSPC <- as.data.frame(unlist(GSPC)) | |
y1 <- data.frame(Date=as.Date(row.names(VIX),"%Y-%m-%d"),"VIX"=VIX$VIX.Close) | |
row.names(y1) <- NULL | |
y2 <- data.frame(Date=as.Date(row.names(GSPC),"%Y-%m-%d"),"GSPC"=GSPC$GSPC.Close) | |
row.names(y2) <- NULL | |
plot(y1$Date, y1$VIX, type="l", col="blue", xlab="Time", ylab="Closing Price") |
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
## Title: ggplot2 Introduction | |
## Description: This line by line analysis, provides an introduction to ggplot2 | |
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc. | |
# install.packages("ggplot2") | |
## Load Library | |
library(ggplot2) | |
# load sample 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
Regex: \[.*\] finds anything in [...] | |
Regex: \(.*\) finds anything in (...) |
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
## Title: ggplot2 Introduction: Part 2 | |
## Description: This line by line analysis, provides an introduction to ggplot2. How to deal with factors, subsetting and labels | |
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc. | |
# install.packages("ggplot2") | |
## Load Library | |
library(ggplot2) | |
# load sample 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
## Title: ggplot2 Introduction: Part 3 | |
## Description: This line by line analysis, provides an introduction to ggplot2. About faceting. | |
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc. | |
# Still working with the same dataset, let's revisit some of our earlier plots. | |
ggplot(d, aes(price)) + geom_histogram() | |
# Apply a basic facet to view more of your data | |
ggplot(d, aes(price)) + geom_histogram() + facet_grid(~cut) |
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
## Title: ggplot2 Introduction: Part IV | |
## Description: This line by line analysis, provides an introduction to ggplot2. Time series. | |
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc. | |
# Review the economics data set from the ggplot2 intro | |
e <- economics | |
str(e) | |
# Let's look at geom_line | |
ggplot(e, aes(date, uempmed)) + geom_line() |
OlderNewer