[[Build An R Package]]
===Bioconductor===
source("http://www.bioconductor.org/biocLite.R")
biocLite([package name])
===Venn Diagram===
library(VennDiagram)
venn.diagram(x=list(A=which(c3[,1]==1),B=which(c3[,2]==1),C=which(c3[,3]==1)),filename="file_dir",height=4,width=4,units="in",category.names=[vector of the name of the classes],cex=2,cat.cex=[category text size]])
===Dynamic Scoping===
Environments in R:
http://adv-r.had.co.nz/Environments.html
Summary:
- Binding environment: how to find the function, where(), package environment.
- Enclosing environment: how the function finds values, environment(), namespace environment.
- Execution environment: environment to host execution.
- Calling environment: where the function is called, parent.frame().
Applications:
MomentEstimate <- function() {
## inherit variables from the calling environment
for(v in c("m1", "m2", "Mu", "Sigma", "family", "s")) {
assign(v, parent.frame()[[v]])
}
## ... codes here ...
## push the updated values to the calling environment
assign("Mu", Mu, envir = parent.frame())
assign("Sigma", Sigma, envir = parent.frame())
}
===Commandline input===
In the file:
commandlineArgs(TRUE)
val <- args[[1]]
var2 <- as.character(args[[2]])
In the commandline:
R CMD BATCH "--args 0.05 test" file.R file.Rout
===Put an expression in figure label===
Include a variable "lambdapr":
..., main = bquote(paste("Sil_Y, ", lambda[p] / lambda[w]== .(lambdapr))), ...
Otherwise
..., main = expression(lambda[p] %/% lambda[w] == 1), ...