Skip to content

Commit 0bcf724

Browse files
committed
Merge pull request #332 from jdavis/r
New R and Rnoweb snippets
2 parents 6de3bb7 + 8c7bb5d commit 0bcf724

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

UltiSnips/r.snippets

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

UltiSnips/rnoweb.snippets

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
priority -50
2+
3+
extends tex, r

0 commit comments

Comments
 (0)