R Under development (unstable) (2014-08-25 r66471) -- "Unsuffered Consequences" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > > # Generate TOC > library(XML) > src <- htmlParse("invert.Rhtml") > hitem <- function(n, level) { + id <- xmlGetAttr(n, "id") + if (is.null(id)) { + NULL + } else { + target <- paste0("#", id) + anchor <- newXMLNode("a", + attrs=list(href=target), + xmlValue(n)) + li <- newXMLNode("li", anchor) + if (level < 3) { + sublist <- hlist(getNodeSet(n, "following-sibling::div[1]")[[1]], + level + 1) + if (!is.null(sublist)) { + addChildren(li, kids=list(sublist)) + } + } + li + } + } > hlist <- function(parent, level) { + hnodes <- getNodeSet(parent, paste0("descendant::h", level)) + list <- newXMLNode("ul") + contents <- lapply(hnodes, hitem, level) + if (length(contents) == 0) { + NULL + } else { + addChildren(list, kids=contents) + } + } > toc <- hlist(getNodeSet(src, "//body")[[1]], 2) > > src <- readLines("invert.Rhtml") > writeLines(gsub("", saveXML(toc), src), "invert.post.Rhtml") > > library(knitr) > knit("invert.post.Rhtml", "invert.html") processing file: invert.post.Rhtml | | | 0% | |. | 1% ordinary text without R code | |.. | 3% label: setup (with options) List of 1 $ include: logi FALSE | |... | 4% inline R code fragments | |.... | 5% label: unnamed-chunk-1 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.... | 7% ordinary text without R code | |..... | 8% label: unnamed-chunk-2 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE compiling temp.tex... Input files: temp.ps Processing: temp.ps Rendering with existing %%BoundingBox: 0 50 612 842 Calculating Bounding Box...ready. %%BoundingBox: 134 661 264 717 Creating output file temp.eps ... ready. | |...... | 10% ordinary text without R code | |....... | 11% label: unnamed-chunk-3 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |........ | 12% ordinary text without R code | |......... | 14% label: unnamed-chunk-4 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |.......... | 15% ordinary text without R code | |........... | 16% label: unnamed-chunk-5 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |............ | 18% ordinary text without R code | |............ | 19% label: unnamed-chunk-6 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |............. | 21% ordinary text without R code | |.............. | 22% label: unnamed-chunk-7 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |............... | 23% ordinary text without R code | |................ | 25% label: unnamed-chunk-8 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |................. | 26% ordinary text without R code | |.................. | 27% label: unnamed-chunk-9 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |................... | 29% ordinary text without R code | |.................... | 30% label: unnamed-chunk-10 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.................... | 32% ordinary text without R code | |..................... | 33% label: unnamed-chunk-11 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE WARNING: ignoring environment value of R_HOME Error in library(knitr) : there is no package called 'knitr' Execution halted | |...................... | 34% label: unnamed-chunk-12 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |....................... | 36% inline R code fragments | |........................ | 37% label: unnamed-chunk-13 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |......................... | 38% ordinary text without R code | |.......................... | 40% label: unnamed-chunk-14 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |........................... | 41% ordinary text without R code | |............................ | 42% label: unnamed-chunk-15 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |............................ | 44% ordinary text without R code | |............................. | 45% label: unnamed-chunk-16 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.............................. | 47% ordinary text without R code | |............................... | 48% label: unnamed-chunk-17 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE WARNING: ignoring environment value of R_HOME Error: could not find function "knit" Execution halted | |................................ | 49% ordinary text without R code | |................................. | 51% label: unnamed-chunk-18 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.................................. | 52% ordinary text without R code | |................................... | 53% label: unnamed-chunk-19 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.................................... | 55% inline R code fragments | |..................................... | 56% label: unnamed-chunk-20 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |..................................... | 58% ordinary text without R code | |...................................... | 59% label: unnamed-chunk-21 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |....................................... | 60% ordinary text without R code | |........................................ | 62% label: unnamed-chunk-22 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |......................................... | 63% ordinary text without R code | |.......................................... | 64% label: unnamed-chunk-23 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |........................................... | 66% ordinary text without R code | |............................................ | 67% label: unnamed-chunk-24 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE Loading required package: bitops | |............................................. | 68% inline R code fragments | |............................................. | 70% label: unnamed-chunk-25 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.............................................. | 71% ordinary text without R code | |............................................... | 73% label: unnamed-chunk-26 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |................................................ | 74% ordinary text without R code | |................................................. | 75% label: unnamed-chunk-27 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |.................................................. | 77% label: unnamed-chunk-28 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |................................................... | 78% ordinary text without R code | |.................................................... | 79% label: unnamed-chunk-29 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |..................................................... | 81% label: unnamed-chunk-30 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |..................................................... | 82% ordinary text without R code | |...................................................... | 84% label: unnamed-chunk-31 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |....................................................... | 85% inline R code fragments | |........................................................ | 86% label: unnamed-chunk-32 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |......................................................... | 88% label: unnamed-chunk-33 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.......................................................... | 89% inline R code fragments | |........................................................... | 90% label: unnamed-chunk-34 (with options) List of 3 $ echo : logi FALSE $ results: chr "hide" $ message: logi FALSE | |............................................................ | 92% ordinary text without R code | |............................................................. | 93% label: unnamed-chunk-35 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |............................................................. | 95% ordinary text without R code | |.............................................................. | 96% label: unnamed-chunk-36 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |............................................................... | 97% inline R code fragments | |................................................................ | 99% label: unnamed-chunk-37 (with options) List of 2 $ echo : logi FALSE $ results: chr "asis" | |.................................................................| 100% ordinary text without R code output file: invert.html [1] "invert.html" > > proc.time() user system elapsed 4.000 0.284 12.345