Skip to content

Commit d1f2316

Browse files
committedMar 30, 2014
Add a few more snippets, fix errors as per honza#332
Hopefully this looks better, @SirVer!
1 parent bd8ef3d commit d1f2316

File tree

1 file changed

+53
-39
lines changed

1 file changed

+53
-39
lines changed
 

‎UltiSnips/r.snippets

+53-39
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,91 @@
1-
snippet #! "Hashbang for Rscript"
1+
priority -50
2+
3+
snippet #! "Hashbang for Rscript (#!)" b
24
#!/usr/bin/env Rscript
35
endsnippet
46

5-
# includes
6-
snippet lib "Import a library"
7+
snippet lib "Import a library (lib)"
78
library(${0:package})
89
endsnippet
910

10-
snippet req "Require a file"
11+
snippet req "Require a file (req)"
1112
require(${0:package})
1213
endsnippet
1314

14-
snippet source "Source a file"
15+
snippet source "Source a file (source)"
1516
source('${0:file}')
1617
endsnippet
1718

18-
# conditionals
19-
snippet if "If statement"
20-
if (${1:condition}) {
19+
snippet if "If statement (if)"
20+
if (${1}) {
2121
${0}
2222
}
2323
endsnippet
2424

25-
snippet el "Else statement"
25+
snippet eif "Else-If statement (eif)"
26+
else if (${1}) {
27+
${0}
28+
}
29+
30+
snippet el "Else statement (el)"
2631
else {
2732
${0}
2833
}
2934
endsnippet
3035

31-
snippet ei "Else-If statement"
32-
else if (${1:condition}) {
36+
snippet eif "Else-If statement (eif)"
37+
else if (${1}) {
3338
${0}
3439
}
3540
endsnippet
3641

37-
# functions
38-
snippet fun "Function definition"
39-
${1:name} <- function (${2:variables}) {
42+
snippet ife "if .. else (ife)"
43+
if (${1}) {
44+
${2}
45+
} else {
46+
${3}
47+
}
48+
endsnippet
49+
50+
snippet wh "while loop (wh)"
51+
while(${1}) {
52+
${2}
53+
}
54+
endsnippet
55+
56+
snippet for "for loop (for)"
57+
for ({${1:item} in ${2:list}) {
58+
${3}
59+
}
60+
endsnippet
61+
62+
snippet fun "Function definition (fun)"
63+
${1:name} <- function (${2}) {
4064
${0}
4165
}
4266
endsnippet
4367

44-
snippet ret "Return call"
68+
snippet ret "Return call (ret)"
4569
return(${0})
4670
endsnippet
4771

48-
# dataframes, lists, etc
49-
snippet df "Data frame"
72+
snippet df "Data frame (df)"
5073
${1:name}[${2:rows}, ${0:cols}]
5174
endsnippet
5275

53-
snippet c "C function"
76+
snippet c "c function (c)"
5477
c(${0:items})
5578
endsnippet
5679

57-
snippet li "List function"
80+
snippet li "list function (li)"
5881
list(${0:items})
5982
endsnippet
6083

61-
snippet mat "Matrix function"
84+
snippet mat "matrix function (mat)"
6285
matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols})
6386
endsnippet
6487

65-
# apply functions
66-
snippet apply "Apply function"
88+
snippet apply "apply function"
6789
apply(${1:array}, ${2:margin}, ${0:function})
6890
endsnippet
6991

@@ -91,46 +113,38 @@ snippet rapply "rapply function"
91113
endsnippet
92114
rapply(${1:list}, ${0:function})
93115

94-
# plot functions
95-
snippet pl "Plot function"
116+
snippet pl "Plot function (pl)"
96117
plot(${1:x}, ${0:y})
97118
endsnippet
98119

99-
snippet ggp "ggplot2 plot"
120+
snippet ggp "ggplot2 plot (ggp)"
100121
ggplot(${1:data}, aes(${0:aesthetics}))
101122
endsnippet
102123

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"
124+
snippet fis "Fisher test (fis)"
111125
fisher.test(${1:x}, ${0:y})
112126
endsnippet
113127

114-
snippet chi "Chi Squared test"
128+
snippet chi "Chi Squared test (chi)"
115129
chisq.test(${1:x}, ${0:y})
116130
endsnippet
117131

118-
snippet tt "t-test"
132+
snippet tt "t-test (tt)"
119133
t.test(${1:x}, ${0:y})
120134
endsnippet
121135

122-
snippet wil "Wilcox test"
136+
snippet wil "Wilcox test (wil)"
123137
wilcox.test(${1:x}, ${0:y})
124138
endsnippet
125139

126-
snippet cor "Correlation test"
140+
snippet cor "Correlation test (cor)"
127141
cor.test(${1:x}, ${0:y})
128142
endsnippet
129143

130-
snippet fte "FTE test"
144+
snippet fte "FTE test (fte)"
131145
var.test(${1:x}, ${0:y})
132146
endsnippet
133147

134-
snippet kvt "KV test"
148+
snippet kvt "KV test (kvt)"
135149
kv.test(${1:x}, ${0:y})
136150
endsnippet

0 commit comments

Comments
 (0)