Skip to content

Commit 53f8dd5

Browse files
committed
Add in r.snippets file
I converted these over from the snipMate r.snippets in the snippets/ directory and removed some ones.
1 parent 77bc9bd commit 53f8dd5

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed

Diff for: UltiSnips/r.snippets

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
snippet #! "Hashbang for Rscript"
2+
#!/usr/bin/env Rscript
3+
endsnippet
4+
5+
# includes
6+
snippet lib "Import a library"
7+
library(${0:package})
8+
endsnippet
9+
10+
snippet req "Require a file"
11+
require(${0:package})
12+
endsnippet
13+
14+
snippet source "Source a file"
15+
source('${0:file}')
16+
endsnippet
17+
18+
# conditionals
19+
snippet if "If statement"
20+
if (${1:condition}) {
21+
${0}
22+
}
23+
endsnippet
24+
25+
snippet el "Else statement"
26+
else {
27+
${0}
28+
}
29+
endsnippet
30+
31+
snippet ei "Else-If statement"
32+
else if (${1:condition}) {
33+
${0}
34+
}
35+
endsnippet
36+
37+
# functions
38+
snippet fun "Function definition"
39+
${1:name} = function (${2:variables}) {
40+
${0}
41+
}
42+
endsnippet
43+
44+
snippet ret "Return call"
45+
return(${0})
46+
endsnippet
47+
48+
# dataframes, lists, etc
49+
snippet df "Data frame"
50+
${1:name}[${2:rows}, ${0:cols}]
51+
endsnippet
52+
53+
snippet c "C function"
54+
c(${0:items})
55+
endsnippet
56+
57+
snippet li "List function"
58+
list(${0:items})
59+
endsnippet
60+
61+
snippet mat "Matrix function"
62+
matrix(${1:data}, nrow=${2:rows}, ncol=${0:cols})
63+
endsnippet
64+
65+
# apply functions
66+
snippet apply "Apply function"
67+
apply(${1:array}, ${2:margin}, ${0:function})
68+
endsnippet
69+
70+
snippet lapply "lapply function"
71+
lapply(${1:list}, ${0:function})
72+
endsnippet
73+
74+
snippet sapply "sapply function"
75+
lapply(${1:list}, ${0:function})
76+
endsnippet
77+
78+
snippet vapply "vapply function"
79+
vapply(${1:list}, ${2:function}, ${0:type})
80+
endsnippet
81+
82+
snippet mapply "mapply function"
83+
mapply(${1:function}, ${0:...})
84+
endsnippet
85+
86+
snippet tapply "tapply function"
87+
tapply(${1:vector}, ${2:index}, ${0:function})
88+
endsnippet
89+
90+
snippet rapply "rapply function"
91+
rapply(${1:list}, ${0:function})
92+
endsnippet
93+
94+
# plot functions
95+
snippet pl "Plot function"
96+
plot(${1:x}, ${0:y})
97+
endsnippet
98+
99+
snippet ggp "ggplot2 plot"
100+
ggplot(${1:data}, aes(${0:aesthetics}))
101+
endsnippet
102+
103+
snippet img "Output an image"
104+
${1:(jpeg,bmp,png,tiff)}(filename="${2:filename}", width=${3}, height=${4}, unit="${5}")
105+
${0:plot}
106+
dev.off()
107+
endsnippet
108+
109+
# statistical test functions
110+
snippet fis "Fisher test"
111+
fisher.test(${1:x}, ${0:y})
112+
endsnippet
113+
114+
snippet chi "Chi Squared test"
115+
chisq.test(${1:x}, ${0:y})
116+
endsnippet
117+
118+
snippet tt "t-test"
119+
t.test(${1:x}, ${0:y})
120+
endsnippet
121+
122+
snippet wil "Wilcox test"
123+
wilcox.test(${1:x}, ${0:y})
124+
endsnippet
125+
126+
snippet cor "Correlation test"
127+
cor.test(${1:x}, ${0:y})
128+
endsnippet
129+
130+
snippet fte "FTE test"
131+
var.test(${1:x}, ${0:y})
132+
endsnippet
133+
134+
snippet kvt "KV test"
135+
kv.test(${1:x}, ${0:y})
136+
endsnippet

0 commit comments

Comments
 (0)