Author: Ruben Arslan
Date: 2019-07-12

# Rmarkdown partial example

#### Ruben Arslan

#### 2019-07-12

# Introduction

For example, you can make enlarge-able plots:

## Graphical relationship

    library(rmdpartials)
    library(ggplot2)
    x <- rnorm(100)
    y <- x + rnorm(100) + 0.5 * x^2
    curve <- ggplot(mapping = aes(x, y)) + geom_point()
    enlarge_plot(curve, large_plot = curve + theme_classic(base_size = 20), plot_name = "myplot")

## Regression

    reg <- lm(y ~ x)
    regression_diagnostics(reg)

| x
--- | ---
(Intercept) | 0.3592409
x | 1.0755503

Values vs. fitted values.

Diagnostics (click to show)

## Write a partial on the fly

    x <- 5
    y <- 9
    partial(text = "`r x` `r y`")

5 9

## Debug

Learn about environments in partials.

    knit_child_debug()

Debug

Working directory

    ## [1] "/private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/Rtmp7E93f7/Rbuilda0a032033b98/rmdpartials/vignettes"

needs_preview()

    ## [1] FALSE

is_interactive()

    ## [1] FALSE

Knitr Output.dir

    ## [1] "/private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/Rtmp7E93f7/Rbuilda0a032033b98/rmdpartials/vignettes"

Child mode

    ## [1] TRUE

Viewer null

    ## [1] TRUE

In tmp dir

    ## [1] FALSE

knitr.in.progress

    ## [1] TRUE

rstudio.notebook.executing

    ## NULL

TESTTHAT_interactive

    ## [1] ""

TESTTHAT

    ## [1] ""

interactive

    ## [1] FALSE

objects in this environment

    ## [1] "is_interactive" "needs_preview"

knitr::opts_knit

    ## $progress
    ## [1] FALSE
    ##
    ## $verbose
    ## [1] FALSE
    ##
    ## $eval.after
    ## [1] "fig.cap"  "fig.scap" "fig.alt"
    ##
    ## $base.dir
    ## NULL
    ##
    ## $base.url
    ## NULL
    ##
    ## $root.dir
    ## NULL
    ##
    ## $child.path
    ## [1] ""
    ##
    ## $upload.fun
    ## function (x)
    ## x
    ## <bytecode: 0x112b15ff0>
    ## <environment: namespace:base>
    ##
    ## $global.device
    ## [1] FALSE
    ##
    ## $global.par
    ## [1] FALSE
    ##
    ## $concordance
    ## [1] FALSE
    ##
    ## $documentation
    ## [1] 1
    ##
    ## $self.contained
    ## [1] TRUE
    ##
    ## $unnamed.chunk.label
    ## [1] "rmdpartial"
    ##
    ## $highr.opts
    ## NULL
    ##
    ## $label.prefix
    ##  table
    ## "tab:"
    ##
    ## $latex.tilde
    ## NULL
    ##
    ## $out.format
    ## [1] "markdown"
    ##
    ## $child
    ## [1] TRUE
    ##
    ## $parent
    ## [1] FALSE
    ##
    ## $tangle
    ## [1] FALSE
    ##
    ## $aliases
    ## NULL
    ##
    ## $header
    ## highlight      tikz    framed
    ##        ""        ""        ""
    ##
    ## $global.pars
    ## NULL
    ##
    ## $rmarkdown.pandoc.from
    ## [1] "markdown+autolink_bare_uris+tex_math_single_backslash"
    ##
    ## $rmarkdown.pandoc.to
    ## [1] "html"
    ##
    ## $rmarkdown.pandoc.args
    ## [1] "--variable"
    ## [2] "bs3=TRUE"
    ## [3] "--standalone"
    ## [4] "--section-divs"
    ## [5] "--template"
    ## [6] "/Users/rubenarslan/Library/R/arm64/4.5/library/rmarkdown/rmd/h/default.html"
    ## [7] "--syntax-highlighting=none"
    ## [8] "--variable"
    ## [9] "highlightjs=1"
    ##
    ## $rmarkdown.pandoc.id_prefix
    ## [1] ""
    ##
    ## $rmarkdown.keep_md
    ## [1] FALSE
    ##
    ## $rmarkdown.df_print
    ## [1] "default"
    ##
    ## $rmarkdown.version
    ## [1] 2
    ##
    ## $rmarkdown.runtime
    ## [1] "static"
    ##
    ## $output.dir
    ## [1] "/private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/Rtmp7E93f7/Rbuilda0a032033b98/rmdpartials/vignettes"

knitr::opts_chunk

    ## $eval
    ## [1] TRUE
    ##
    ## $echo
    ## [1] FALSE
    ##
    ## $results
    ## [1] "markup"
    ##
    ## $tidy
    ## [1] FALSE
    ##
    ## $tidy.opts
    ## NULL
    ##
    ## $collapse
    ## [1] FALSE
    ##
    ## $prompt
    ## [1] FALSE
    ##
    ## $comment
    ## [1] "##"
    ##
    ## $highlight
    ## [1] TRUE
    ##
    ## $size
    ## [1] "normalsize"
    ##
    ## $background
    ## [1] "#F7F7F7"
    ##
    ## $strip.white
    ## [1] TRUE
    ##
    ## $cache
    ## [1] FALSE
    ##
    ## $cache.path
    ## [1] "rmdpartials_cache/html/f080a7cff6_"
    ##
    ## $cache.vars
    ## NULL
    ##
    ## $cache.lazy
    ## [1] TRUE
    ##
    ## $dependson
    ## NULL
    ##
    ## $autodep
    ## [1] FALSE
    ##
    ## $cache.rebuild
    ## [1] FALSE
    ##
    ## $fig.keep
    ## [1] "high"
    ##
    ## $fig.show
    ## [1] "asis"
    ##
    ## $fig.align
    ## [1] "default"
    ##
    ## $fig.path
    ## [1] "/private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/Rtmp7E93f7/Rbuilda0a032033b98/rmdpartials/vignettes/rmdpartials_files/figure-html/f080a7cff6_"
    ##
    ## $dev
    ## [1] "png"
    ##
    ## $dev.args
    ## NULL
    ##
    ## $dpi
    ## [1] 96
    ##
    ## $fig.ext
    ## NULL
    ##
    ## $fig.width
    ## [1] 7
    ##
    ## $fig.height
    ## [1] 5
    ##
    ## $fig.env
    ## [1] "figure"
    ##
    ## $fig.cap
    ## NULL
    ##
    ## $fig.scap
    ## NULL
    ##
    ## $fig.lp
    ## [1] "fig:"
    ##
    ## $fig.subcap
    ## NULL
    ##
    ## $fig.pos
    ## [1] ""
    ##
    ## $out.width
    ## NULL
    ##
    ## $out.height
    ## NULL
    ##
    ## $out.extra
    ## NULL
    ##
    ## $fig.retina
    ## [1] 2
    ##
    ## $external
    ## [1] TRUE
    ##
    ## $sanitize
    ## [1] FALSE
    ##
    ## $interval
    ## [1] 1
    ##
    ## $aniopts
    ## [1] "controls,loop"
    ##
    ## $warning
    ## [1] TRUE
    ##
    ## $error
    ## [1] FALSE
    ##
    ## $message
    ## [1] TRUE
    ##
    ## $render
    ## NULL
    ##
    ## $ref.label
    ## NULL
    ##
    ## $child
    ## NULL
    ##
    ## $engine
    ## [1] "R"
    ##
    ## $split
    ## [1] FALSE
    ##
    ## $include
    ## [1] TRUE
    ##
    ## $purl
    ## [1] TRUE

Sys.getenv()

    ## __CF_USER_TEXT_ENCODING
    ##                         0x1F7:0x0:0x0
    ## __CFBundleIdentifier    com.todesktop.230313mzl4w4u92
    ## _R_CHECK_LENGTH_1_LOGIC2_
    ##                         TRUE
    ## ANDROID_HOME            /Users/rubenarslan/Library/Android/sdk
    ## BIBINPUTS               .:/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/share/texmf/bibtex/bib:
    ## BSTINPUTS               .:/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/share/texmf/bibtex/bst:
    ## CALLR_CHILD_R_LIBS      /private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/RtmpgdIc2b/temp_libpath930913a5d5cc:/Users/rubenarslan/Library/R/arm64/4.5/library:/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
    ## CALLR_CHILD_R_LIBS_SITE
    ##                         %S
    ## CALLR_CHILD_R_LIBS_USER
    ##                         /private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/RtmpgdIc2b/temp_libpath930913a5d5cc:/Users/rubenarslan/Library/R/arm64/4.5/library:/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
    ## CALLR_IS_RUNNING        true
    ## CALLR_R_LIBS_SITE_BAK   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/site-library
    ## CALLR_R_LIBS_USER_BAK   /Users/rubenarslan/Library/R/arm64/4.5/library
    ## CLAUDE_CODE_SSE_PORT    14590
    ## CLICOLOR                1
    ## COLORTERM               truecolor
    ## COLUMNS                 105
    ## COMMAND_MODE            unix2003
    ## CURSOR_TRACE_ID         5beffc6b9d2c4272b5b84a0ba00feae5
    ## CYGWIN                  nodosfilewarning
    ## DISPLAY                 /private/tmp/com.apple.launchd.kxr3jnq73y/org.xquartz:0
    ## DYLD_FALLBACK_LIBRARY_PATH
    ##                         /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib:/Library/Java/JavaVirtualMachines/jdk-11.0.18+10/Contents/Home/lib/server
    ## EDITOR                  vi
    ## GIT_ASKPASS             /Applications/Cursor.app/Contents/Resources/app/extensions/git/dist/askpass.sh
    ## HOME                    /Users/rubenarslan
    ## HOMEBREW_CELLAR         /opt/homebrew/Cellar
    ## HOMEBREW_PREFIX         /opt/homebrew
    ## HOMEBREW_REPOSITORY     /opt/homebrew
    ## INFOPATH                /opt/homebrew/share/info:/opt/homebrew/share/info:
    ## LANG                    en_US.UTF-8
    ## LC_ALL                  en_US.UTF-8
    ## LC_COLLATE              C
    ## LINES                   11
    ## LN_S                    ln -s
    ## LOGNAME                 rubenarslan
    ## MAKE                    make
    ## MallocNanoZone          0
    ## PAGER                   /usr/bin/less
    ## PATH                    /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/bin:/Applications/quarto/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Applications/arx-3.6.0.app/Contents/bin:/Library/TeX/Root/bin/x86_64-darwin/:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/rubenarslan/Library/Android/sdk/tools:/Users/rubenarslan/Library/Android/sdk/platform-tools:/Users/rubenarslan/.local/bin
    ## PKGLOAD_PARENT_TEMPDIR
    ##                         /var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T//RtmpgdIc2b
    ## PROCESSX_PS93092c8f20d3_1771775266
    ##                         YES
    ## PWD                     /private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/Rtmp7E93f7/Rbuilda0a032033b98/rmdpartials
    ## R_ARCH
    ## R_BIN                   /usr/local/bin/R
    ## R_BROWSER               false
    ## R_BUILD_TEMPLIB         /var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T//Rtmp7E93f7/Rinsta0a0723d91ce
    ## R_BZIPCMD               /usr/bin/bzip2
    ## R_CMD                   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/bin/Rcmd
    ## R_DEFAULT_PACKAGES
    ## R_DOC_DIR               /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/doc
    ## R_ENVIRON
    ## R_ENVIRON_USER
    ## R_GZIPCMD               /usr/bin/gzip
    ## R_HOME                  /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources
    ## R_INCLUDE_DIR           /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include
    ## R_LIBS                  /private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/Rtmp7E93f7/Rinsta0a0723d91ce:/private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/RtmpgdIc2b/temp_libpath930913a5d5cc:/Users/rubenarslan/Library/R/arm64/4.5/library:/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
    ## R_LIBS_SITE             /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/site-library
    ## R_LIBS_USER             /private/var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/RtmpgdIc2b/temp_libpath930913a5d5cc:/Users/rubenarslan/Library/R/arm64/4.5/library:/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
    ## R_MAKEVARS_USER         /var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T//RtmpgdIc2b/file93095a6455b
    ## R_MAX_VSIZE             16000000000
    ## R_OSTYPE                unix
    ## R_PAPERSIZE             a4
    ## R_PAPERSIZE_USER        a4
    ## R_PDFVIEWER             false
    ## R_PLATFORM              aarch64-apple-darwin20
    ## R_PRINTCMD              lpr
    ## R_PROFILE
    ## R_PROFILE_USER
    ## R_QPDF                  /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/bin/qpdf
    ## R_RD4PDF                times,inconsolata,hyper
    ## R_SESSION_TMPDIR        /var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T//RtmpTMWB3J
    ## R_SHARE_DIR             /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/share
    ## R_STRIP_SHARED_LIB      strip -x
    ## R_STRIP_STATIC_LIB      strip -S
    ## R_TESTS
    ## R_TEXI2DVICMD           /opt/R/arm64/bin/texi2dvi
    ## R_UNZIPCMD              /usr/bin/unzip
    ## R_VERSION               4.5.1
    ## R_ZIPCMD                /usr/bin/zip
    ## RENV_PATHS_ROOT         /Library/Frameworks/renv
    ## SED                     /usr/bin/sed
    ## SHELL                   /bin/bash
    ## SHLVL                   4
    ## SSH_AUTH_SOCK           /private/tmp/com.apple.launchd.vOxIKmRWXY/Listeners
    ## TAR                     /usr/bin/tar
    ## TERM                    xterm-256color
    ## TERM_PROGRAM            vscode
    ## TERM_PROGRAM_VERSION    2.5.17
    ## TEXINPUTS               .:/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/share/texmf/tex/latex:
    ## TMPDIR                  /var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/
    ## TWITTER_PAT             /Users/rubenarslan/.rtweet_token4.rds
    ## USER                    rubenarslan
    ## VSCODE_GIT_ASKPASS_EXTRA_ARGS
    ##
    ## VSCODE_GIT_ASKPASS_MAIN
    ##                         /Applications/Cursor.app/Contents/Resources/app/extensions/git/dist/askpass-main.js
    ## VSCODE_GIT_ASKPASS_NODE
    ##                         /Applications/Cursor.app/Contents/Frameworks/Cursor
    ##                         Helper (Plugin).app/Contents/MacOS/Cursor
    ##                         Helper (Plugin)
    ## VSCODE_GIT_IPC_AUTH_TOKEN
    ##                         b11a8c6731291dab80de4c8060ea6f1cb50a3043df7e9c053661c4f4a5e0b07d
    ## VSCODE_GIT_IPC_HANDLE   /var/folders/tr/lgwjmdgd72bckr1hj5gd_7640000gq/T/vscode-git-922f6172c7.sock
    ## XPC_FLAGS               0x0
    ## XPC_SERVICE_NAME        0

options()

    ## $add.smooth
    ## [1] TRUE
    ##
    ## $bitmapType
    ## [1] "quartz"
    ##
    ## $browser
    ## [1] "false"
    ##
    ## $browserNLdisabled
    ## [1] FALSE
    ##
    ## $callr.condition_handler_cli_message
    ## function (msg)
    ## {
    ##     custom_handler <- getOption("cli.default_handler")
    ##     if (is.function(custom_handler)) {
    ##         custom_handler(msg)
    ##     }
    ##     else {
    ##         cli_server_default(msg)
    ##     }
    ## }
    ## <bytecode: 0x1068eb4b0>
    ## <environment: namespace:cli>
    ##
    ## $catch.script.errors
    ## [1] FALSE
    ##
    ## $CBoundsCheck
    ## [1] FALSE
    ##
    ## $check.bounds
    ## [1] FALSE
    ##
    ## $citation.bibtex.max
    ## [1] 1
    ##
    ## $continue
    ## [1] "+ "
    ##
    ## $contrasts
    ##         unordered           ordered
    ## "contr.treatment"      "contr.poly"
    ##
    ## $defaultPackages
    ## [1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"
    ##
    ## $demo.ask
    ## [1] "default"
    ##
    ## $deparse.cutoff
    ## [1] 60
    ##
    ## $device
    ## function (width = 7, height = 7, ...)
    ## {
    ##     grDevices::pdf(NULL, width, height, ...)
    ## }
    ## <bytecode: 0x112c6f2e8>
    ## <environment: namespace:knitr>
    ##
    ## $device.ask.default
    ## [1] FALSE
    ##
    ## $digits
    ## [1] 7
    ##
    ## $dplyr.show_progress
    ## [1] TRUE
    ##
    ## $dvipscmd
    ## [1] "dvips"
    ##
    ## $echo
    ## [1] FALSE
    ##
    ## $editor
    ## [1] "vi"
    ##
    ## $encoding
    ## [1] "native.enc"
    ##
    ## $example.ask
    ## [1] "default"
    ##
    ## $expressions
    ## [1] 5000
    ##
    ## $help.search.types
    ## [1] "vignette" "demo"     "help"
    ##
    ## $help.try.all.packages
    ## [1] FALSE
    ##
    ## $htmltools.preserve.raw
    ## [1] TRUE
    ##
    ## $HTTPUserAgent
    ## [1] "R (4.5.1 aarch64-apple-darwin20 aarch64 darwin20)"
    ##
    ## $install.packages.compile.from.source
    ## [1] "interactive"
    ##
    ## $internet.info
    ## [1] 2
    ##
    ## $keep.parse.data
    ## [1] TRUE
    ##
    ## $keep.parse.data.pkgs
    ## [1] FALSE
    ##
    ## $keep.source
    ## [1] FALSE
    ##
    ## $keep.source.pkgs
    ## [1] FALSE
    ##
    ## $knitr.duplicate.label
    ## [1] "allow"
    ##
    ## $knitr.in.progress
    ## [1] TRUE
    ##
    ## $knitr.knit2html.force_v1
    ## [1] TRUE
    ##
    ## $locatorBell
    ## [1] TRUE
    ##
    ## $mailer
    ## [1] "mailto"
    ##
    ## $matprod
    ## [1] "default"
    ##
    ## $max.contour.segments
    ## [1] 25000
    ##
    ## $max.print
    ## [1] 99999
    ##
    ## $menu.graphics
    ## [1] TRUE
    ##
    ## $na.action
    ## [1] "na.omit"
    ##
    ## $nwarnings
    ## [1] 50
    ##
    ## $OutDec
    ## [1] "."
    ##
    ## $pager
    ## [1] "/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/bin/pager"
    ##
    ## $papersize
    ## [1] "a4"
    ##
    ## $PCRE_limit_recursion
    ## [1] NA
    ##
    ## $PCRE_study
    ## [1] FALSE
    ##
    ## $PCRE_use_JIT
    ## [1] TRUE
    ##
    ## $pdfviewer
    ## [1] "false"
    ##
    ## $pkgType
    ## [1] "both"
    ##
    ## $printcmd
    ## [1] "lpr"
    ##
    ## $prompt
    ## [1] "> "
    ##
    ## $repos
    ##                          CRAN
    ## "https://cloud.r-project.org"
    ##
    ## $rl_word_breaks
    ## [1] " \t\n\"\\'`><=%;,|&{()}"
    ##
    ## $rlang_trace_top_env
    ## <environment: R_GlobalEnv>
    ##
    ## $scipen
    ## [1] 0
    ##
    ## $show.coef.Pvalues
    ## [1] TRUE
    ##
    ## $show.error.messages
    ## [1] TRUE
    ##
    ## $show.signif.stars
    ## [1] TRUE
    ##
    ## $showErrorCalls
    ## [1] TRUE
    ##
    ## $showNCalls
    ## [1] 50
    ##
    ## $showWarnCalls
    ## [1] FALSE
    ##
    ## $str
    ## $str$strict.width
    ## [1] "no"
    ##
    ## $str$digits.d
    ## [1] 3
    ##
    ## $str$vec.len
    ## [1] 4
    ##
    ## $str$list.len
    ## [1] 99
    ##
    ## $str$deparse.lines
    ## NULL
    ##
    ## $str$drop.deparse.attr
    ## [1] TRUE
    ##
    ## $str$formatNum
    ## function (x, ...)
    ## format(x, trim = TRUE, drop0trailing = TRUE, ...)
    ## <environment: 0x1043a3830>
    ##
    ##
    ## $str.dendrogram.last
    ## [1] "`"
    ##
    ## $texi2dvi
    ## [1] "/opt/R/arm64/bin/texi2dvi"
    ##
    ## $tikzMetricsDictionary
    ## [1] "rmdpartials-tikzDictionary"
    ##
    ## $timeout
    ## [1] 60
    ##
    ## $try.outFile
    ## A connection with
    ## description ""
    ## class       "file"
    ## mode        "w+b"
    ## text        "binary"
    ## opened      "opened"
    ## can read    "yes"
    ## can write   "yes"
    ##
    ## $ts.eps
    ## [1] 1e-05
    ##
    ## $ts.S.compat
    ## [1] FALSE
    ##
    ## $unzip
    ## [1] "/usr/bin/unzip"
    ##
    ## $useFancyQuotes
    ## [1] FALSE
    ##
    ## $verbose
    ## [1] FALSE
    ##
    ## $warn
    ## [1] 1
    ##
    ## $warning.length
    ## [1] 1000
    ##
    ## $warnPartialMatchArgs
    ## [1] FALSE
    ##
    ## $warnPartialMatchAttr
    ## [1] FALSE
    ##
    ## $warnPartialMatchDollar
    ## [1] FALSE
    ##
    ## $width
    ## [1] 80