-
Notifications
You must be signed in to change notification settings - Fork 27
Celda Development Robust and Efficient Code
Zhe Wang edited this page May 24, 2019
·
7 revisions
See http://bioconductor.org/developers/how-to/efficient-code/
- Use
TRUE
andFALSE
. Do not useT
orF
. - Use
isTRUE
andisFALSE
. From the documentation of logical operators in R: "isTRUE(x)
is the same as{is.logical(x) && length(x) == 1 && !is.na(x) && x}
.isFALSE()
is defined analogously. Consequently,if (isTRUE(cond))
may be preferable toif (cond)
because ofNA
s." - Use
vapply()
. Do not usesapply()
. If possible, do not useunlist(lapply())
. - Use
seq(5)
,seq_len(5)
, andseq_along(a)
. Do not use1:5
or1:length(a)
. - Do not use
paste
withinmessage
,stop
, orwarning
functions. These functions paste the texts for you. - Use
paste(rep("-", 50), collapse = "")
. Do not use"--------------------------------------------------------------------"
.