Skip to content

Commit 558e934

Browse files
committed
one more vignette update
1 parent 32272b8 commit 558e934

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ Rcpp.pro.user
1414
*.autosave
1515
.#*
1616

17-
*.tar.gz
17+
*.tar.gz
18+
19+
vignettes/*_cache

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
2018-07-26 Dirk Eddelbuettel <[email protected]>
22

33
* vignettes/Rcpp-FAQ.Rmd: Use collapse: true
4+
* vignettes/Rcpp-introduction.Rmd: Idem
45

56
2018-07-25 Dirk Eddelbuettel <[email protected]>
67

vignettes/Rcpp-introduction.Rmd

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ watermark: false
5555
footer_contents: "Rcpp Vignette"
5656

5757
# Produce a pinp document
58-
output: pinp::pinp
58+
output:
59+
pinp::pinp:
60+
collapse: true
5961

6062
# Local additiona of a few definitions we use
6163
header-includes: >
@@ -86,6 +88,7 @@ vignette: >
8688
```{r setup, include=FALSE}
8789
knitr::opts_chunk$set(cache=TRUE)
8890
library(Rcpp)
91+
options("width"=50, digits=5)
8992
```
9093

9194

@@ -193,7 +196,7 @@ and
193196
As a first step, and chiefly to establish that the toolchain is set up correctly, consider
194197
a minimal use case such as the following:
195198

196-
```{r evalCpp, eval=FALSE}
199+
```{r evalCpp}
197200
library("Rcpp")
198201
evalCpp("2 + 2")
199202
```
@@ -225,6 +228,7 @@ isOddR <- function(num = 10L) {
225228
result <- (num %% 2L == 1L)
226229
return(result)
227230
}
231+
isOddR(42L)
228232
```
229233

230234
The operator `%%` implements the $\bmod$ operation in \rlangns. For the default
@@ -259,7 +263,7 @@ that represents the \cpp code. Upon calling the `cppFunction()`, and similarly t
259263
earlier example involving `evalCpp()`, the \cpp code is both _compiled_ and _linked_, and
260264
then _imported_ into \rlang under the name of the function supplied (_e.g._ here `isOddCpp()`).
261265

262-
```{r isOddRcpp, cache=TRUE, eval=FALSE}
266+
```{r isOddRcpp}
263267
library("Rcpp")
264268
cppFunction("
265269
bool isOddCpp(int num = 10) {
@@ -509,7 +513,7 @@ set.seed(123)
509513
rnorm(3)
510514
```
511515

512-
# Translating Code from \rlang into \rcppns: A Bootstrapping Example
516+
# Translating Code from \rlang into \rcppns: Bootstrap Example
513517

514518
Statistical inference relied primarily upon asymptotic theory until
515519
\cite{Efron:1979:Bootstrap} proposed the bootstrap. Bootstrapping is known
@@ -564,7 +568,7 @@ make_boot_graph <- function(ds, actual, type, ylim){
564568
abline(v = actual, col = "orange2", lwd = 2)
565569
lines(density(ds))
566570
}
567-
pdf("bootstrap.pdf", width=6.5, height=3.25)
571+
pdf("figures/bootstrap.pdf", width=6.5, height=3.25)
568572
par(mfrow=c(1,2))
569573
make_boot_graph(result_r[,1], 21, "Mean", c(0, 1.23))
570574
make_boot_graph(result_r[,2], 10, "SD", c(0, 1.85))
@@ -573,7 +577,7 @@ dev.off()
573577

574578
\begin{figure*}
575579
\begin{center}
576-
\includegraphics[width=6.5in, height=3.25in]{bootstrap}
580+
\includegraphics[width=6.5in, height=3.25in]{figures/bootstrap}
577581
\caption{Results of the bootstrapping procedure for sample mean and variance.}
578582
\label{fig:bootstrap-graphs}
579583
\end{center}
@@ -809,13 +813,10 @@ Rcpp::List fastLm(const arma::mat& X,
809813
const arma::colvec& y) {
810814
// Dimension information
811815
int n = X.n_rows, p = X.n_cols;
812-
813816
// Fit model y ~ X
814817
arma::colvec coef = arma::solve(X, y);
815-
816818
// Compute the residuals
817819
arma::colvec res = y - X*coef;
818-
819820
// Estimated variance of the random error
820821
double s2 =
821822
std::inner_product(res.begin(), res.end(),

vignettes/figures/bootstrap.pdf

10.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)