Skip to content

Commit c549dd8

Browse files
version 0.1.1: merge branch appendString
Create AppendStrings.R
2 parents ccd247a + 73d2851 commit c549dd8

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Package: RG
22
Type: Package
33
Title: R-Golf, codegolf functions for R
4-
Version: 0.1.0
5-
Author: Who wrote it
4+
Version: 0.1.1
5+
Author: J. Dubbeldam
66
Maintainer: J. Dubbeldam <jarkodubbeldam@gmail.com>
77
Description: This are functions that serve as replacement for long pieces of code, to make R that little bit golfier.
88
License: CC BY-NC 4.0
99
Encoding: UTF-8
1010
LazyData: true
1111
RoxygenNote: 6.0.1
12+
Date: 2017-07-19

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export("+")
34
export(C)

R/AppendStrings.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#' Addition
2+
#'
3+
#' Modified addition operator to work with strings.
4+
#'
5+
#' If any of the arguments is of class \code{character}, the two arguments are concatenated and returned as string. Else the base implementation of \code{+} is called.
6+
#'
7+
#' @param e1 LHS
8+
#' @param e2 RHS
9+
#'
10+
#' @return A string or numeric.
11+
#' @export
12+
#'
13+
#' @examples
14+
#' {
15+
#' 1+1
16+
#' "a"+"b"
17+
#' "a"+1+2
18+
#' 1+2+"a"
19+
#' }
20+
`+` <- function(e1, e2){
21+
if(is.character(c(e1, e2))){
22+
paste0(e1, e2)
23+
} else {
24+
.Primitive("+")(e1, e2)
25+
}
26+
}
27+
28+
29+
30+

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ One of those pesky things about packages, especially when you need to use multip
2525

2626
## Current included functions:
2727

28-
[`C`](R\C.R): Numerical concatenation. Paste digits together and output a numeric.
28+
[`C`](https://github.com/JarkoDubbeldam/RG/blob/appendString/R/C.R): Numerical concatenation. Paste digits together and output a numeric.
29+
[`+`](https://github.com/JarkoDubbeldam/RG/blob/appendString/R/AppendStrings.R): Augmented to be useful for strings. Works like `paste0` on strings.

man/plus.Rd

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)