File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 11priority -50
22
3+ global !p
4+ import os
5+ from vimsnippets import complete
6+
7+ FIELD_TYPES = [
8+ ' character' ,
9+ ' data.frame' ,
10+ ' integer' ,
11+ ' list' ,
12+ ' logical' ,
13+ ' matrix' ,
14+ ' numeric' ,
15+ ' vector' ]
16+ endglobal
17+
318snippet #! " Hashbang for Rscript (#!)" b
419#!/usr/bin/env Rscript
520endsnippet
621
22+ snippet setwd " Set workingdir" b
23+ setwd("${1: `!p snip.rv = os.getcwd()` } ")
24+ endsnippet
25+
26+ snippet as " Apply type on variable" w
27+ as.$1 `!p snip.rv = complete(t[1 ], FIELD_TYPES ) ` (${2} ${VISUAL})
28+ endsnippet
29+
30+ snippet is " Test type on variable" w
31+ is.$1 `!p snip.rv = complete(t[1 ], FIELD_TYPES ) ` (${2} ${VISUAL})
32+ endsnippet
33+
34+ snippet dl " Download and install a package" b
35+ download.file("${1: ${VISUAL:url to package } }", destfile = "${2: ${1 / . * \/ (\S * )$ / (? 1:$ 1) / ga } } ")
36+ install.packages("$2 ", type = "source", repos = NULL)
37+ library("${3: ${2 / ^ (\w + )_. * $ / (? 1:$ 1) / ga } } ")
38+ endsnippet
39+
740snippet lib " Import a library"
841library(${0: package } )
942endsnippet
You can’t perform that action at this time.
0 commit comments