Skip to content

Commit ebd3504

Browse files
authored
Re-align vignettes (#61)
* Refocus vignette on solving linear regression and remove package use * Improve the package usage note
1 parent 155c384 commit ebd3504

File tree

2 files changed

+47
-27
lines changed

2 files changed

+47
-27
lines changed

vignettes/package-usage.Rmd

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: "Using RcppEnsmallen in Your Own R Package"
3+
author: James Joseph Balamuta
4+
abstract: |
5+
This vignette describes the best practices for using RcppEnsmallen in your
6+
own R package.
7+
output: rmarkdown::html_vignette
8+
vignette: >
9+
%\VignetteIndexEntry{Using RcppEnsmallen in Your Own R Package}
10+
%\VignetteEngine{knitr::rmarkdown}
11+
%\VignetteEncoding{UTF-8}
12+
---
13+
14+
# Overview
15+
16+
RcppEnsmallen is best used within an _R_ package.
17+
The setup for `RcppEnsmallen`'s use mirrors that of other `Rcpp`-based projects.
18+
In particular, the `DESCRIPTION` file requires the `LinkingTo` field and
19+
two files inside the `src/` to establish the necessary compilation options.
20+
In the next two sections, we show the modifications.
21+
22+
## DESCRIPTION file
23+
24+
Open your R package's `DESCRIPTION` file. Ensure that the `LinkingTo` directive
25+
is present and contains:
26+
27+
```bash
28+
LinkingTo: Rcpp, RcppArmadillo (>= 0.9.800.0.0), RcppEnsmallen (>= 0.2.20.0.1)
29+
```
30+
31+
## Makevars inside the src/ Directory
32+
33+
Next, the `src/` directory must contain both a `Makevars` and `Makevars.win`
34+
file. Each file must have the same contents of:
35+
36+
```bash
37+
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
38+
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
39+
```
40+
41+
The `Makevars.win` file provides the appropriate configuration for Windows
42+
while `Makevars` acts on Unix-alike systems like macOS, Linux, and Solaris.

vignettes/using-rcppensmallen.Rmd

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: "Using RcppEnsmallen"
2+
title: "Solving Linear Regression using Numeric Optimization"
33
author: James Joseph Balamuta and Dirk Eddelbuettel
44
abstract: |
5-
Contained within are examples related to using RcppEnsmallen in everyday
6-
work alongside of creating an _R_ package with it.
5+
In this vignette, we describe how to use RcppEnsmallen in a standalone
6+
C++ file.
77
output: rmarkdown::html_vignette
88
vignette: >
9-
%\VignetteIndexEntry{Using RcppEnsmallen}
9+
%\VignetteIndexEntry{Solving Linear Regression using Numeric Optimization}
1010
%\VignetteEngine{knitr::rmarkdown}
1111
%\VignetteEncoding{UTF-8}
1212
---
@@ -45,7 +45,7 @@ $$RSS\left( \beta \right) = \left( { \mathbf{y} - \mathbf{X} \beta } \right)^{\t
4545

4646
The objective function we wish to minimize would be defined as:
4747

48-
$$f(\beta) = \rVert y - X\beta\lVert_2$$
48+
$$f(\beta) = \rVert \mathbf{y} - \mathbf{X}\beta\lVert_2$$
4949

5050
The gradient is defined as:
5151

@@ -185,25 +185,3 @@ rownames(compare_coefs) = paste0("Beta", seq_len(nrow(compare_coefs)))
185185
knitr::kable(compare_coefs, longtable = FALSE, caption = "Comparison of Estimated Coefficients")
186186
```
187187

188-
# Package Usage
189-
190-
RcppEnsmallen is best used within an _R_ package. The setup for `RcppEnsmallen`'s
191-
use mirrors that of other `Rcpp`-based projects. In particular, the
192-
`DESCRIPTION` file requires the `LinkingTo` field to contain:
193-
194-
```bash
195-
LinkingTo: Rcpp, RcppArmadillo (>= 0.9.800.0.0), RcppEnsmallen (>= 0.2.18.0.1)
196-
```
197-
198-
Next, the `src/` directory must contain both a `Makevars` and `Makevars.win`
199-
file with:
200-
201-
```bash
202-
CXX_STD = CXX11
203-
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
204-
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
205-
```
206-
207-
The `Makevars.win` file provides the appropriate configuration for Windows
208-
while `Makevars` acts on Unix-alike systems like macOS, Linux, and Solaris.
209-

0 commit comments

Comments
 (0)