Skip to content

Commit be37d9b

Browse files
committed
As submitted to CRAN
1 parent 7f30dc6 commit be37d9b

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: formulops
22
Title: Mathematical Operations on R Formula
3-
Version: 0.0.0.9003
3+
Version: 0.5.0
44
Authors@R: person("Bill", "Denney", email="wdenney@humanpredictions.com", role=c("aut", "cre"), comment=c(ORCID="0000-0002-5759-428X"))
55
Description: Perform mathematical operations on R formula (add, subtract, multiply, etc.) and substitute parts of formula.
66
Depends: R (>= 3.5)
@@ -11,3 +11,5 @@ RoxygenNote: 7.0.2
1111
Suggests:
1212
covr,
1313
testthat
14+
URL: https://github.com/billdenney/formulops
15+
BugReports: https://github.com/billdenney/formulops/issues

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,25 @@ install.packages("formulops")
2222

2323
## Example
2424

25-
This is a basic example which shows you how to solve a common problem:
25+
A few common examples of modifying a formula are given below.
2626

2727
``` r
2828
library(formulops)
29-
## basic example code
29+
# Replace a with c in the formula
30+
modify_formula(a~b, find=quote(a), replace=quote(c))
31+
# Replace a with c+d in the formula
32+
modify_formula(a~b, find=quote(a), replace=quote(c+d))
33+
# More complex parts can be replaced, too
34+
modify_formula(a~b/c, find=quote(b/c), replace=quote(d))
35+
# Multiple replacements can occur simultaneously
36+
modify_formula(a~b/c+d, find=list(quote(b/c), quote(d)), replace=list(quote(d), quote(e)))
37+
# Function arguments can be expanded
38+
modify_formula(a~b(c), find=quote(c), replace=quote(formulops_expand(d, e)))
39+
```
40+
41+
A substituting formula is a simple way to generate a complex formula from several simpler formulae. Parentheses are appropriately added, if required.
42+
43+
``` r
44+
foo <- substituting_formula(y~x1+x2, x1~x3*x4, x2~x5/x6+x7)
45+
as.formula(foo)
3046
```

0 commit comments

Comments
 (0)