haotu : an open lab notebook

2013/08/31

merge two dataframes by row names

Filed under: Manipulate Data in R, R — S @ 01:47

Given that the (row)names of X and Y exist and might intersect, this will merge the two vectors/dataframes.


merge(X,Y,by=0,all=TRUE)

http://stackoverflow.com/questions/7739578/merge-data-frames-based-on-rownames-in-r

Advertisements

2013/08/30

Install quantstrat

Filed under: Finance, R, R — S @ 04:07


install.packages("FinancialInstrument", repos="http://R-Forge.R-project.org")

install.packages("blotter", repos="http://R-Forge.R-project.org")

install.packages("quantstrat", repos="http://R-Forge.R-project.org")

http://www.programmingr.com/content/installing-quantstrat-r-forge-and-source/

save R objects one at a time saveRDS

Filed under: Manipulate Data in R, R — S @ 02:30


x <- "save me"
saveRDS(x,file=paste(x,".rds",sep=""))
save.me<-readRDS(paste(x,".rds",sep=""))
save.me

Long Version
http://ucfagls.wordpress.com/2012/04/01/saving-and-loading-r-objects/

2013/08/27

Add a vertical line to a histogram in R

Filed under: R, R graphics — S @ 02:10


hist(x)
abline(v = mx, col = "blue", lwd = 2)

http://stackoverflow.com/questions/6557977/add-mean-value-to-histogram-in-r

Blog at WordPress.com.