2012-08-16 23:41:25 -04:00
|
|
|
snippet #!
|
|
|
|
#!/usr/bin/env Rscript
|
|
|
|
|
|
|
|
# includes
|
|
|
|
snippet lib
|
2013-11-16 14:45:48 -05:00
|
|
|
library(${0:package})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet req
|
2013-11-16 14:45:48 -05:00
|
|
|
require(${0:package})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet source
|
2013-11-16 14:45:48 -05:00
|
|
|
source('${0:file}')
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
# conditionals
|
|
|
|
snippet if
|
|
|
|
if (${1:condition}) {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet el
|
|
|
|
else {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet ei
|
|
|
|
else if (${1:condition}) {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
2014-07-02 07:18:18 -04:00
|
|
|
# loops
|
|
|
|
snippet wh
|
|
|
|
while(${1}) {
|
|
|
|
${2}
|
|
|
|
}
|
|
|
|
snippet for
|
|
|
|
for (${1:item} in ${2:list}) {
|
|
|
|
${3}
|
|
|
|
}
|
2020-04-25 21:56:16 -04:00
|
|
|
snippet foreach
|
|
|
|
foreach (${1:item} = ${2:list}) {
|
|
|
|
${3}
|
|
|
|
}
|
2014-07-02 07:18:18 -04:00
|
|
|
|
2012-08-16 23:41:25 -04:00
|
|
|
# functions
|
|
|
|
snippet fun
|
2014-07-02 07:18:18 -04:00
|
|
|
${1:name} <- function (${2:variables}) {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet ret
|
2013-11-16 14:45:48 -05:00
|
|
|
return(${0})
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
# dataframes, lists, etc
|
|
|
|
snippet df
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:name}[${2:rows}, ${0:cols}]
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet c
|
2013-11-16 14:45:48 -05:00
|
|
|
c(${0:items})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet li
|
2013-11-16 14:45:48 -05:00
|
|
|
list(${0:items})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mat
|
2014-07-02 07:18:18 -04:00
|
|
|
matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols})
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
# apply functions
|
|
|
|
snippet apply
|
2013-11-16 14:45:48 -05:00
|
|
|
apply(${1:array}, ${2:margin}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet lapply
|
2013-11-16 14:45:48 -05:00
|
|
|
lapply(${1:list}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sapply
|
2013-11-16 14:45:48 -05:00
|
|
|
lapply(${1:list}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet vapply
|
2013-11-16 14:45:48 -05:00
|
|
|
vapply(${1:list}, ${2:function}, ${0:type})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mapply
|
2013-11-16 14:45:48 -05:00
|
|
|
mapply(${1:function}, ${0:...})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet tapply
|
2013-11-16 14:45:48 -05:00
|
|
|
tapply(${1:vector}, ${2:index}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rapply
|
2013-11-16 14:45:48 -05:00
|
|
|
rapply(${1:list}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
# plyr functions
|
|
|
|
snippet dd
|
2013-11-16 14:45:48 -05:00
|
|
|
ddply(${1:frame}, ${2:variables}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet dl
|
2013-11-16 14:45:48 -05:00
|
|
|
dlply(${1:frame}, ${2:variables}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet da
|
2013-11-16 14:45:48 -05:00
|
|
|
daply(${1:frame}, ${2:variables}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet d_
|
2013-11-16 14:45:48 -05:00
|
|
|
d_ply(${1:frame}, ${2:variables}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
snippet ad
|
2013-11-16 14:45:48 -05:00
|
|
|
adply(${1:array}, ${2:margin}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet al
|
2013-11-16 14:45:48 -05:00
|
|
|
alply(${1:array}, ${2:margin}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet aa
|
2013-11-16 14:45:48 -05:00
|
|
|
aaply(${1:array}, ${2:margin}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet a_
|
2013-11-16 14:45:48 -05:00
|
|
|
a_ply(${1:array}, ${2:margin}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
snippet ld
|
2013-11-16 14:45:48 -05:00
|
|
|
ldply(${1:list}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ll
|
2013-11-16 14:45:48 -05:00
|
|
|
llply(${1:list}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet la
|
2013-11-16 14:45:48 -05:00
|
|
|
laply(${1:list}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet l_
|
2013-11-16 14:45:48 -05:00
|
|
|
l_ply(${1:list}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
snippet md
|
2013-11-16 14:45:48 -05:00
|
|
|
mdply(${1:matrix}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ml
|
2013-11-16 14:45:48 -05:00
|
|
|
mlply(${1:matrix}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ma
|
2013-11-16 14:45:48 -05:00
|
|
|
maply(${1:matrix}, ${0:function})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet m_
|
2013-11-16 14:45:48 -05:00
|
|
|
m_ply(${1:matrix}, ${0:function})
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
# plot functions
|
|
|
|
snippet pl
|
2013-11-16 14:45:48 -05:00
|
|
|
plot(${1:x}, ${0:y})
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet ggp
|
2013-11-16 14:45:48 -05:00
|
|
|
ggplot(${1:data}, aes(${0:aesthetics}))
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet img
|
2014-07-02 07:18:18 -04:00
|
|
|
${1:(jpeg,bmp,png,tiff)}(filename = '${2:filename}', width = ${3}, height = ${4}, unit = '${5}')
|
2013-11-16 14:45:48 -05:00
|
|
|
${0:plot}
|
2013-04-13 13:45:21 -04:00
|
|
|
dev.off()
|
|
|
|
|
|
|
|
# statistical test functions
|
|
|
|
snippet fis
|
2013-11-16 14:45:48 -05:00
|
|
|
fisher.test(${1:x}, ${0:y})
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet chi
|
2013-11-16 14:45:48 -05:00
|
|
|
chisq.test(${1:x}, ${0:y})
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet tt
|
2013-11-16 14:45:48 -05:00
|
|
|
t.test(${1:x}, ${0:y})
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet wil
|
2013-11-16 14:45:48 -05:00
|
|
|
wilcox.test(${1:x}, ${0:y})
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet cor
|
2013-11-16 14:45:48 -05:00
|
|
|
cor.test(${1:x}, ${0:y})
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet fte
|
2013-11-16 14:45:48 -05:00
|
|
|
var.test(${1:x}, ${0:y})
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet kvt
|
2013-11-16 14:45:48 -05:00
|
|
|
kv.test(${1:x}, ${0:y})
|