## ----echo=FALSE----------------------------
library(tufte)
#knitr::opts_chunk$set(results = "hide", echo = FALSE)
## ----setup, include=FALSE, cache=FALSE----------
library(knitr)
options(replace.assign=FALSE,width=50)
opts_chunk$set(fig.path='knitr_figure/graphics-',
cache.path='knitr_cache/graphics-',
fig.align='center',
dev='pdf', fig.width=5, fig.height=5,
fig.show='hold', cache=FALSE, par=TRUE)
knit_hooks$set(crop=hook_pdfcrop)
knit_hooks$set(par = function(before, options, envir) {
if (before && options$fig.show!='none') {
par(mar=c(3,3,2,1),cex.lab=.95,cex.axis=.9,
mgp=c(2,.7,0),tcl=-.01, las=1)
}}, crop=hook_pdfcrop)
## ---- fig.margin = TRUE, out.width="\\textwidth", echo = FALSE----
knitr::include_graphics("logo.png")
## ----eval=FALSE---------------------------------
# library("pkg")
# hello()
## ----eval=FALSE---------------------------------
# help("hello")
## -----------------------------------------------
#' @export
#' @details
#' @aliases
## ----message=FALSE------------------------------
library("devtools")
library("roxygen2")
## ----eval=FALSE---------------------------------
# install.packages(c("devtools", "roxygen2"))
## ----eval=FALSE---------------------------------
# library("roxygen2")
# roxygenise(".")
## -----------------------------------------------
#' @export
## -----------------------------------------------
#' @export
hello <- function() {
print("Hello, world!")
}
## ----message=FALSE, eval=FALSE------------------
# library("pkg")
## ----eval=FALSE---------------------------------
# hello()
## ----eval=FALSE---------------------------------
# # Generated by roxygen2: do not edit by hand
# export(hello)
## -----------------------------------------------
#' @export
add = function(x, y) {
return(x + y)
}
## ----message=FALSE, eval=FALSE------------------
# library("pkg")
# add(1, 2)
## -----------------------------------------------
check_numeric = function(x) all(is.numeric(x))
## -----------------------------------------------
add = function(x, y) {
if(!check_numeric(c(x, y))) stop("Not numeric")
x + y
}
## ----results="hide", eval=FALSE-----------------
# library("pkg")
# check_numeric(1)
## ----eval=FALSE---------------------------------
# pkg:::check_numeric(1)
## ----eval=FALSE---------------------------------
# pkg::add(1, 1)
## ----eval=FALSE---------------------------------
# #' @title A function for adding
# #'
# #' @description A really good adding function.
# #' Perhaps the best function ever!
# #'
# #' A work of pure genius.
# #' @param x a number
# #' @param y another number
# #' @return a number
# #' @export
# #' @examples
# #' add(5, 10)
# #' ## Can also use negative numbers
# #' add(-5, 10)
# add = function(x, y) {
# if(!check_numeric(c(x, y))) stop("Not numeric")
# x + y
# }
## ----results="hide", eval=FALSE-----------------
# example(add)
## ----eval=FALSE---------------------------------
# times = function(x, y) multiply(x, y)
## -----------------------------------------------
#' @rdname multiply
## ----eval=FALSE, tidy=FALSE---------------------
# install.packages("drat")
## ----eval=FALSE, tidy=FALSE---------------------
# drat::addRepo("jr-packages")
## ----eval=FALSE, tidy=FALSE---------------------
# install.packages("jrAdvPackage")
## -----------------------------------------------
library("jrAdvPackage")
div(10, 2)
## -----------------------------------------------
#' @importFrom jrAdvPackage div
## -----------------------------------------------
#' add("A", "B")
## ----eval=FALSE, tidy=FALSE---------------------
# ## Entry in data_help_files.R
# ## Name is name of the data set.
# #' @name moby
# #' @aliases moby_sample
# #' @title Moby Dick word count
# #' @description The frequency of occurrence of unique words
# #' in the novel Moby Dick by Herman Melville.
# #'
# #' The data set moby_sample is 2000 values sampled from the
# #' moby data set.
# #' @docType data
# #' @format A vector
# #' @source M. E. J. Newman, "Power laws, Pareto distributions
# #' and Zipf's law." Contemporary Physics 46, 323 (2005).
# NULL
## -----------------------------------------------
example_data = data.frame(x = runif(10), y = runif(10))
## ----eval=FALSE---------------------------------
# save(example_data, file="data/example_data.RData")
## ----eval=FALSE---------------------------------
# vignette(package="knitr")
## ----eval=FALSE---------------------------------
# browseVignettes(package="knitr")
## ----eval=FALSE---------------------------------
# ---
# title: "My very first vignette"
# author: "Colin Gillespie and Robin Lovelace"
# output: rmarkdown::html_vignette
# vignette: >
# %\VignetteIndexEntry{My very first vignette}
# %\VignetteEngine{knitr::rmarkdown}
# %\VignetteEncoding{UTF-8}
# ---
#
# ## My first package
#
# This is my **first** package vignette.
# I can include mathematics, such as $x^2$.
# R code is also nicely formatted and displayed.
#
## -----------------------------------------------
x = runif(10)
x
## -----------------------------------------------
plot(x)
## ----eval=FALSE, tidy=FALSE---------------------
# install.packages("pkg_1.0.tar.gz", repos=NULL,
# type="source")
## ----eval=FALSE, tidy=FALSE---------------------
# library("pkg")
# ?pkg
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.