1
0
Fork 0
mirror of synced 2024-11-09 10:48:58 -05:00
ultimate-vim/sources_non_forked/vim-snippets/snippets/r.snippets

132 lines
2.4 KiB
Text
Raw Normal View History

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