Skip to content

Commit c42479e

Browse files
Updated readme
1 parent 31f0b5a commit c42479e

File tree

7 files changed

+53
-5
lines changed

7 files changed

+53
-5
lines changed

README.Rmd

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ knitr::opts_chunk$set(
1515

1616
# ContourFunctions
1717

18-
[![Travis-CI Build Status](https://travis-ci.org/CollinErickson/contour.svg?branch=master)](https://travis-ci.org/CollinErickson/contour)
18+
[![Travis-CI Build Status](https://travis-ci.org/CollinErickson/ContourFunctions.svg?branch=master)](https://travis-ci.org/CollinErickson/ContourFunctions)
1919
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/ContourFunctions)](https://cran.r-project.org/package=ContourFunctions)
2020
[![Codecov test coverage](https://codecov.io/gh/CollinErickson/ContourFunctions/branch/master/graph/badge.svg)](https://codecov.io/gh/CollinErickson/ContourFunctions?branch=master)
2121

@@ -33,6 +33,21 @@ The main functions are:
3333

3434
* `cf`: Passes arguments to `cf_function` or `cf_data` depending on whether the first argument is a function or numeric.
3535

36+
All of these functions make the plot using base graphics by default.
37+
To make plots using ggplot2, add the argument `gg=TRUE`,
38+
or put g in front of the function name.
39+
E.g., `gcf_data(...)` is the same as `cf_data(..., gg=TRUE)`,
40+
and makes a similar plot to `cf_data` but using ggplot2.
41+
42+
There are two functions for making plots in higher dimensions:
43+
44+
* `cf_4dim`: Plots functions with four inputs by making a series
45+
of contour plots.
46+
47+
* `cf_highdim`: Plots for higher dimensional inputs by making a
48+
contour plot for each pair of input dimensions and holding the other
49+
inputs constant or averaging over them.
50+
3651

3752
## Installation
3853

@@ -47,21 +62,26 @@ devtools::install_github("CollinErickson/contour")
4762

4863
## Usage
4964

50-
```{r cf_grid}
65+
Plot a grid of data:
5166

67+
```{r cf_grid}
5268
library(ContourFunctions)
5369
a <- b <- seq(-4*pi, 4*pi, len = 27)
5470
r <- sqrt(outer(a^2, b^2, "+"))
5571
cf_grid(a, b, cos(r^2)*exp(-r/(2*pi)))
5672
```
5773

58-
74+
Plot a function with two input dimensions:
5975

6076
```{r cf_func}
6177
f1 <- function(r) cos(r[1]^2 + r[2]^2)*exp(-sqrt(r[1]^2 + r[2]^2)/(2*pi))
6278
cf_func(f1, xlim = c(-4*pi, 4*pi), ylim = c(-4*pi, 4*pi))
6379
```
6480

81+
Using data with two inputs and an output,
82+
fit a Gaussian process model and show the
83+
contour surface with dots where the points are:
84+
6585
```{r cf_data}
6686
set.seed(0)
6787
x <- runif(20)
@@ -70,13 +90,17 @@ z <- exp(-(x-.5)^2-5*(y-.5)^2)
7090
cf_data(x,y,z)
7191
```
7292

93+
For more than two input dimensions:
94+
7395
```{r cf_highdim}
7496
friedman <- function(x) {
7597
10*sin(pi*x[1]*x[2]) + 20*(x[3]-.5)^2 + 10*x[4] + 5*x[5]
7698
}
7799
cf_highdim(friedman, 5, color.palette=topo.colors)
78100
```
79101

102+
For (three or) four inputs dimensions:
103+
80104
```{r cf_4dim}
81105
cf_4dim(function(x) {x[1] + x[2]^2 + sin(2*pi*x[3])})
82106
```

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ContourFunctions
55

66
[![Travis-CI Build
7-
Status](https://travis-ci.org/CollinErickson/contour.svg?branch=master)](https://travis-ci.org/CollinErickson/contour)
7+
Status](https://travis-ci.org/CollinErickson/ContourFunctions.svg?branch=master)](https://travis-ci.org/CollinErickson/ContourFunctions)
88
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/ContourFunctions)](https://cran.r-project.org/package=ContourFunctions)
99
[![Codecov test
1010
coverage](https://codecov.io/gh/CollinErickson/ContourFunctions/branch/master/graph/badge.svg)](https://codecov.io/gh/CollinErickson/ContourFunctions?branch=master)
@@ -26,6 +26,20 @@ The main functions are:
2626
- `cf`: Passes arguments to `cf_function` or `cf_data` depending on
2727
whether the first argument is a function or numeric.
2828

29+
All of these functions make the plot using base graphics by default. To
30+
make plots using ggplot2, add the argument `gg=TRUE`, or put g in front
31+
of the function name. E.g., `gcf_data(...)` is the same as `cf_data(...,
32+
gg=TRUE)`, and makes a similar plot to `cf_data` but using ggplot2.
33+
34+
There are two functions for making plots in higher dimensions:
35+
36+
- `cf_4dim`: Plots functions with four inputs by making a series of
37+
contour plots.
38+
39+
- `cf_highdim`: Plots for higher dimensional inputs by making a
40+
contour plot for each pair of input dimensions and holding the other
41+
inputs constant or averaging over them.
42+
2943
## Installation
3044

3145
# It can be installed like any other package
@@ -37,8 +51,9 @@ The main functions are:
3751

3852
## Usage
3953

40-
``` r
54+
Plot a grid of data:
4155

56+
``` r
4257
library(ContourFunctions)
4358
a <- b <- seq(-4*pi, 4*pi, len = 27)
4459
r <- sqrt(outer(a^2, b^2, "+"))
@@ -47,13 +62,18 @@ cf_grid(a, b, cos(r^2)*exp(-r/(2*pi)))
4762

4863
![](tools/README-cf_grid-1.png)<!-- -->
4964

65+
Plot a function with two input dimensions:
66+
5067
``` r
5168
f1 <- function(r) cos(r[1]^2 + r[2]^2)*exp(-sqrt(r[1]^2 + r[2]^2)/(2*pi))
5269
cf_func(f1, xlim = c(-4*pi, 4*pi), ylim = c(-4*pi, 4*pi))
5370
```
5471

5572
![](tools/README-cf_func-1.png)<!-- -->
5673

74+
Using data with two inputs and an output, fit a Gaussian process model
75+
and show the contour surface with dots where the points are:
76+
5777
``` r
5878
set.seed(0)
5979
x <- runif(20)
@@ -64,6 +84,8 @@ cf_data(x,y,z)
6484

6585
![](tools/README-cf_data-1.png)<!-- -->
6686

87+
For more than two input dimensions:
88+
6789
``` r
6890
friedman <- function(x) {
6991
10*sin(pi*x[1]*x[2]) + 20*(x[3]-.5)^2 + 10*x[4] + 5*x[5]
@@ -73,6 +95,8 @@ cf_highdim(friedman, 5, color.palette=topo.colors)
7395

7496
![](tools/README-cf_highdim-1.png)<!-- -->
7597

98+
For (three or) four inputs dimensions:
99+
76100
``` r
77101
cf_4dim(function(x) {x[1] + x[2]^2 + sin(2*pi*x[3])})
78102
```

tools/README-cf_4dim-1.png

5.12 KB
Loading

tools/README-cf_data-1.png

-10 Bytes
Loading

tools/README-cf_func-1.png

0 Bytes
Loading

tools/README-cf_grid-1.png

-9 Bytes
Loading

tools/README-cf_highdim-1.png

10.8 KB
Loading

0 commit comments

Comments
 (0)