-
Notifications
You must be signed in to change notification settings - Fork 0
/
operators.R
executable file
·39 lines (31 loc) · 946 Bytes
/
operators.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# TRUE if no element of x matches the regex rx
`%!~%` <- function(x, rx){
out <- any( rxout <- regexpr(rx, x) == -1 )
assign( "..nm", which(rxout), parent.frame() )
out
}
# negation of %in%
`%!in%` <- function(...) !`%in%`(...)
# wrap all around %in%
`%allin%` <- function(...) all( `%in%`(...) )
`%!allin%` <- function(...) !all( `%in%`(...) )
# string concatenation
`%.%` <- function(s1, s2) {
paste(s1, s2, sep = "")
}
# .. with a newline
`%.n%` <- function(s1, s2) {
paste(s1, s2, sep = "\n", collapse = "\n")
}
# .. with a new line and a tabulation
`%.nt%` <- `%.tn%` <- function(s1, s2) {
paste(s1, s2, sep = "\n\t")
}
# .. remove a pattern from a string
`%-~%` <- function(txt, rx){
gsub( rx, '', txt )
}
# assign value to the value of name
`%<-%` <- function(name, value){
assign( name, value, parent.frame() )
}