From 59b1e5aeb70675d4ebc4ea9ce26bec5c5539a063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20Dar=C3=B3czi?= Date: Mon, 27 May 2013 13:30:56 +0200 Subject: [PATCH] split long lines in docs --- R/brew.R | 22 +++++++++++---- R/convert.R | 5 +++- R/evals.R | 56 ++++++++++++++++++++++++-------------- R/pandoc.R | 15 +++++++--- man/Pandoc.brew.Rd | 22 +++++++++++---- man/Pandoc.convert.Rd | 5 +++- man/evals.Rd | 54 ++++++++++++++++++++++-------------- man/pandoc.list.return.Rd | 5 +++- man/pandoc.table.return.Rd | 10 +++++-- 9 files changed, 131 insertions(+), 63 deletions(-) diff --git a/R/brew.R b/R/brew.R index f31d4433..630dbb91 100644 --- a/R/brew.R +++ b/R/brew.R @@ -28,7 +28,10 @@ #' \item John MacFarlane (2012): _Pandoc User's Guide_. \url{http://johnmacfarlane.net/pandoc/README.html} #' } #' @examples \dontrun{ -#' text <- paste('# Header', '', 'What a lovely list:\n<%=as.list(runif(10))%>', 'A wide table:\n<%=mtcars[1:3, ]%>', 'And a nice chart:\n\n<%=plot(1:10)%>', sep = '\n') +#' text <- paste('# Header', '', +#' 'What a lovely list:\n<%=as.list(runif(10))%>', +#' 'A wide table:\n<%=mtcars[1:3, ]%>', +#' 'And a nice chart:\n\n<%=plot(1:10)%>', sep = '\n') #' Pandoc.brew(text = text) #' Pandoc.brew(text = text, output = tempfile(), convert = 'html') #' Pandoc.brew(text = text, output = tempfile(), convert = 'pdf') @@ -38,14 +41,21 @@ #' #' ## package bundled examples #' Pandoc.brew(system.file('examples/minimal.brew', package='pander')) -#' Pandoc.brew(system.file('examples/minimal.brew', package='pander'), output = tempfile(), convert = 'html') +#' Pandoc.brew(system.file('examples/minimal.brew', package='pander'), +#' output = tempfile(), convert = 'html') #' Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander')) -#' Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), output = tempfile(), convert = 'html') +#' Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), +#' output = tempfile(), convert = 'html') #' #' ## brew returning R objects -#' str(Pandoc.brew(text='Pi equals to <%=pi%>.\nAnd here are some random data:\n<%=runif(10)%>')) -#' str(Pandoc.brew(text='# Header <%=1%>\nPi is <%=pi%> which is smaller then <%=2%>.\nfoo\nbar\n <%=3%>\n<%=mtcars[1:2,]%>')) -#' str(Pandoc.brew(text='<%for (i in 1:5) {%>\n Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>')) +#' str(Pandoc.brew(text='Pi equals to <%=pi%>. +#' And here are some random data:\n<%=runif(10)%>')) +#' +#' str(Pandoc.brew(text='# Header <%=1%>\nPi is <%=pi%> which is smaller then <%=2%>. +#' foo\nbar\n <%=3%>\n<%=mtcars[1:2,]%>')) +#' +#' str(Pandoc.brew(text='<%for (i in 1:5) {%> +#' Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>')) #' } Pandoc.brew <- function(file = stdin(), output = stdout(), convert = FALSE, open = TRUE, graph.name, graph.dir, graph.hi.res = FALSE, text = NULL, envir = parent.frame()) { diff --git a/R/convert.R b/R/convert.R index 66d7aa56..46f571f1 100644 --- a/R/convert.R +++ b/R/convert.R @@ -43,7 +43,10 @@ openFileInOS <- function(f) { #' @examples \dontrun{ #' Pandoc.convert(text = c('# Demo', 'with a paragraph')) #' Pandoc.convert('http://rapporter.github.com/pander/minimal.md') -#' ## Note: the generated HTML is not showing images with relative path from the above file. Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an online markdown file to other formats with this function, please pre-process the file to have absolute paths instead. +#' ## Note: the generated HTML is not showing images with relative path from the above file. +#' ## Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an +#' ## online markdown file to other formats with this function, please pre-process the file +#' ## to have absolute paths instead. #' } Pandoc.convert <- function(f, text, format = 'html', open = TRUE, options = '', footer = TRUE, proc.time, portable.html = TRUE) { diff --git a/R/evals.R b/R/evals.R index 94746d5a..8492df5e 100644 --- a/R/evals.R +++ b/R/evals.R @@ -447,7 +447,8 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval #' 'ggplot(mtcars) + geom_point(aes(x = hp, y = mpg))') #' evals(txt) #' -#' ## the same commands in one string but also evaluating the `plot` with `text` (note the leading "+" on the beginning of `text...` line) +#' ## the same commands in one string but also evaluating the `plot` with `text` +#' ## (note the leading "+" on the beginning of `text...` line) #' txt <- 'df <- mtcars #' plot(mtcars$hp, pch = 19) #' +text(mtcars$hp, label = rownames(mtcars), pos = 4) @@ -462,35 +463,39 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval #' #' ## adding a caption to a plot #' evals('set.caption("FOO"); plot(1:10)') -#' ## `plot` is started with a `+` to eval the codes in the same chunk (no extra chunk with NULL result) +#' ## `plot` is started with a `+` to eval the codes in the same chunk +#' ## (no extra chunk with NULL result) #' evals('set.caption("FOO"); +plot(1:10)') #' #' ## handling warnings #' evals('chisq.test(mtcars$gear, mtcars$hp)') -#' evals(list(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', 'chisq.test(mtcars$gear, mtcars$hp)')), parse = F) -#' evals(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', 'chisq.test(mtcars$gear, mtcars$hp)')) +#' evals(list(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', +#' 'chisq.test(mtcars$gear, mtcars$hp)')), parse = FALSE) +#' evals(c('chisq.test(mtcars$gear, mtcars$am)', +#' 'pi', +#' 'chisq.test(mtcars$gear, mtcars$hp)')) #' #' ## handling errors #' evals('runiff(20)') #' evals('Old MacDonald had a farm\\dots') #' evals('## Some comment') #' evals(c('runiff(20)', 'Old MacDonald had a farm?')) -#' evals(list(c('runiff(20)', 'Old MacDonald had a farm?')), parse = F) +#' evals(list(c('runiff(20)', 'Old MacDonald had a farm?')), parse = FALSE) #' evals(c('mean(1:10)', 'no.R.function()')) -#' evals(list(c('mean(1:10)', 'no.R.function()')), parse = F) +#' evals(list(c('mean(1:10)', 'no.R.function()')), parse = FALSE) #' evals(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')) -#' evals(list(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')), parse = F) +#' evals(list(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')), parse = FALSE) #' evals(c('no.R.object', 'Old MacDonald had a farm\\dots', 'pi')) -#' evals('no.R.object;Old MacDonald had a farm\\dots;pi', parse = F) -#' evals(list(c('no.R.object', 'Old MacDonald had a farm\\dots', 'pi')), parse = F) +#' evals('no.R.object;Old MacDonald had a farm\\dots;pi', parse = FALSE) +#' evals(list(c('no.R.object', 'Old MacDonald had a farm\\dots', 'pi')), parse = FALSE) #' #' ## graph options #' evals('plot(1:10)') #' evals('plot(1:10);plot(2:20)') #' evals('plot(1:10)', graph.output = 'jpg') #' evals('plot(1:10)', height = 800) -#' evals('plot(1:10)', height = 800, hi.res = T) -#' evals('plot(1:10)', graph.output = 'pdf', hi.res = T) +#' evals('plot(1:10)', height = 800, hi.res = TRUE) +#' evals('plot(1:10)', graph.output = 'pdf', hi.res = TRUE) #' evals('plot(1:10)', res = 30) #' evals('plot(1:10)', graph.name = 'myplot') #' evals(list('plot(1:10)', 'plot(2:20)'), graph.name = 'myplots-%d') @@ -498,15 +503,18 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval #' evals('x <- runif(100);plot(x)', graph.env = TRUE) #' evals(c('plot(1:10)', 'plot(2:20)'), graph.env = TRUE) #' evals(c('x <- runif(100)', 'plot(x)','y <- runif(100)', 'plot(y)'), graph.env = TRUE) -#' evals(list(c('x <- runif(100)', 'plot(x)'), c('y <- runif(100)', 'plot(y)')), graph.env = TRUE, parse = F) +#' evals(list( +#' c('x <- runif(100)', 'plot(x)'), +#' c('y <- runif(100)', 'plot(y)')), +#' graph.env = TRUE, parse = FALSE) #' evals('plot(1:10)', graph.recordplot = TRUE) #' ## unprinted lattice plot #' evals('histogram(mtcars$hp)', graph.recordplot = TRUE) #' #' ## caching #' system.time(evals('plot(mtcars)')) -#' system.time(evals('plot(mtcars)')) # running again to see the speed-up :) -#' system.time(evals('plot(mtcars)', cache = FALSE)) # cache disabled +#' system.time(evals('plot(mtcars)')) # running again to see the speed-up :) +#' system.time(evals('plot(mtcars)', cache = FALSE)) # cache disabled #' #' ## caching mechanism does check what's inside a variable: #' x <- mtcars @@ -517,12 +525,13 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval #' system.time(evals('plot(x)')) #' #' ## stress your CPU - only once! -#' evals('x <- sapply(rep(mtcars$hp, 1e3), mean)') # run it again! +#' evals('x <- sapply(rep(mtcars$hp, 1e3), mean)') # run it again! #' #' ## play with cache #' require(lattice) #' evals('histogram(rep(mtcars$hp, 1e5))') -#' ## nor run the below call - which would return the cached version of the above call :) +#' ## nor run the below call +#' ## that would return the cached version of the above call :) #' f <- histogram #' g <- rep #' A <- mtcars$hp @@ -552,9 +561,11 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval #' evals('matrix(runif(25), 5, 5)', hooks = list('matrix' = round)) #' #' ## setting default hook -#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), hooks = list('default'=round)) +#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), +#' hooks = list('default'=round)) #' ## round all values except for matrices -#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), hooks = list(matrix = 'print', 'default' = round)) +#' evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), +#' hooks = list(matrix = 'print', 'default' = round)) #' #' # advanced hooks #' hooks <- list('numeric' = list(round, 2), 'matrix' = list(round, 1)) @@ -572,11 +583,14 @@ eval.msgs <- function(src, env = NULL, showInvisible = FALSE, graph.unify = eval #' # note the following will not be filtered! #' evals('matrix(1,1,1)', length = 1) #' -#' # if you do not want to let such things be eval-ed in the middle of a string use it with other filters :) +#' # if you do not want to let such things be eval-ed in the middle of a string +#' # use it with other filters :) #' evals('matrix(1,1,1)', length = 1, classes = 'numeric') #' -#'# hooks & filtering -#' evals('matrix(5,5,5)', hooks = list('matrix' = pander.return), output = 'result') +#' # hooks & filtering +#' evals('matrix(5,5,5)', +#' hooks = list('matrix' = pander.return), +#' output = 'result') #' #' # eval-ing chunks in given environment #' myenv <- new.env() diff --git a/R/pandoc.R b/R/pandoc.R index a9535f80..23a66222 100644 --- a/R/pandoc.R +++ b/R/pandoc.R @@ -374,7 +374,10 @@ pandoc.title <- function(...) #' pandoc.list(letters[1:5], loose = TRUE) #' #' ## nested lists -#' l <- list("First list element", rep.int('sub element', 5), "Second element", list('F', 'B', 'I', c('phone', 'pad', 'talics'))) +#' l <- list("First list element", +#' rep.int('sub element', 5), +#' "Second element", +#' list('F', 'B', 'I', c('phone', 'pad', 'talics'))) #' pandoc.list(l) #' pandoc.list(l, loose = TRUE) #' pandoc.list(l, 'roman') @@ -474,7 +477,9 @@ pandoc.list <- function(...) #' pandoc.table(table(state.division, state.region)) #' pandoc.table(table(state.division, state.region), justify = 'centre') #' -#' m <- data.frame(a=c(1, -500, 10320, 23, 77), b=runif(5), c=c('a', 'bb', 'ccc', 'dddd', 'eeeee')) +#' m <- data.frame(a = c(1, -500, 10320, 23, 77), +#' b = runif(5), +#' c = c('a', 'bb', 'ccc', 'dddd', 'eeeee')) #' pandoc.table(m) #' pandoc.table(m, justify = c('right', 'left', 'centre')) #' @@ -483,7 +488,8 @@ pandoc.list <- function(...) #' pandoc.table(mtcars, caption = 'Only once after the first part!') #' #' ## tables with line breaks in cells -#' ## Note: line breaks are removed from table content and added automatically based on "split.cells" parameter! +#' ## NOTE: line breaks are removed from table content +#' ## and added automatically based on "split.cells" parameter! #' t <- data.frame(a = c('hundreds\nof\nmouses', '3 cats'), b=c('FOO is nice', 'BAR\nBAR2')) #' pandoc.table(t) #' pandoc.table(t, split.cells = 5) @@ -495,7 +501,8 @@ pandoc.list <- function(...) #' pandoc.table(t, style = "grid") #' pandoc.table(t, style = "grid", split.cells = 5) #' pandoc.table(t, style = "simple") -#' tryCatch(pandoc.table(t, style = "simple", split.cells = 5), error = function(e) 'Yeah, no newline support in simple tables') +#' tryCatch(pandoc.table(t, style = "simple", split.cells = 5), +#' error = function(e) 'Yeah, no newline support in simple tables') #' pandoc.table(t, style = "rmarkdown") #' #' ## highlight cells diff --git a/man/Pandoc.brew.Rd b/man/Pandoc.brew.Rd index 7e138a28..39be61c4 100644 --- a/man/Pandoc.brew.Rd +++ b/man/Pandoc.brew.Rd @@ -84,7 +84,10 @@ } \examples{ \dontrun{ -text <- paste('# Header', '', 'What a lovely list:\\n<\%=as.list(runif(10))\%>', 'A wide table:\\n<\%=mtcars[1:3, ]\%>', 'And a nice chart:\\n\\n<\%=plot(1:10)\%>', sep = '\\n') +text <- paste('# Header', '', + 'What a lovely list:\\n<\%=as.list(runif(10))\%>', + 'A wide table:\\n<\%=mtcars[1:3, ]\%>', + 'And a nice chart:\\n\\n<\%=plot(1:10)\%>', sep = '\\n') Pandoc.brew(text = text) Pandoc.brew(text = text, output = tempfile(), convert = 'html') Pandoc.brew(text = text, output = tempfile(), convert = 'pdf') @@ -94,14 +97,21 @@ Pandoc.brew(text='<\%for (i in 1:5) {\%>\\n Pi has a lot (<\%=i\%>) of power: <\ ## package bundled examples Pandoc.brew(system.file('examples/minimal.brew', package='pander')) -Pandoc.brew(system.file('examples/minimal.brew', package='pander'), output = tempfile(), convert = 'html') +Pandoc.brew(system.file('examples/minimal.brew', package='pander'), + output = tempfile(), convert = 'html') Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander')) -Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), output = tempfile(), convert = 'html') +Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), + output = tempfile(), convert = 'html') ## brew returning R objects -str(Pandoc.brew(text='Pi equals to <\%=pi\%>.\\nAnd here are some random data:\\n<\%=runif(10)\%>')) -str(Pandoc.brew(text='# Header <\%=1\%>\\nPi is <\%=pi\%> which is smaller then <\%=2\%>.\\nfoo\\nbar\\n <\%=3\%>\\n<\%=mtcars[1:2,]\%>')) -str(Pandoc.brew(text='<\%for (i in 1:5) {\%>\\n Pi has a lot (<\%=i\%>) of power: <\%=pi^i\%><\%}\%>')) +str(Pandoc.brew(text='Pi equals to <\%=pi\%>. +And here are some random data:\\n<\%=runif(10)\%>')) + +str(Pandoc.brew(text='# Header <\%=1\%>\\nPi is <\%=pi\%> which is smaller then <\%=2\%>. +foo\\nbar\\n <\%=3\%>\\n<\%=mtcars[1:2,]\%>')) + +str(Pandoc.brew(text='<\%for (i in 1:5) {\%> +Pi has a lot (<\%=i\%>) of power: <\%=pi^i\%><\%}\%>')) } } \references{ diff --git a/man/Pandoc.convert.Rd b/man/Pandoc.convert.Rd index dfc87acc..146203c0 100644 --- a/man/Pandoc.convert.Rd +++ b/man/Pandoc.convert.Rd @@ -57,7 +57,10 @@ \dontrun{ Pandoc.convert(text = c('# Demo', 'with a paragraph')) Pandoc.convert('http://rapporter.github.com/pander/minimal.md') -## Note: the generated HTML is not showing images with relative path from the above file. Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an online markdown file to other formats with this function, please pre-process the file to have absolute paths instead. +## Note: the generated HTML is not showing images with relative path from the above file. +## Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an +## online markdown file to other formats with this function, please pre-process the file +## to have absolute paths instead. } } \references{ diff --git a/man/evals.Rd b/man/evals.Rd index 04f34cd6..c7f4e4de 100644 --- a/man/evals.Rd +++ b/man/evals.Rd @@ -317,7 +317,8 @@ txt <- list('df <- mtcars', 'ggplot(mtcars) + geom_point(aes(x = hp, y = mpg))') evals(txt) -## the same commands in one string but also evaluating the `plot` with `text` (note the leading "+" on the beginning of `text...` line) +## the same commands in one string but also evaluating the `plot` with `text` +## (note the leading "+" on the beginning of `text...` line) txt <- 'df <- mtcars plot(mtcars$hp, pch = 19) +text(mtcars$hp, label = rownames(mtcars), pos = 4) @@ -332,35 +333,39 @@ evals('message(20);message(20)', parse = FALSE) ## adding a caption to a plot evals('set.caption("FOO"); plot(1:10)') -## `plot` is started with a `+` to eval the codes in the same chunk (no extra chunk with NULL result) +## `plot` is started with a `+` to eval the codes in the same chunk +## (no extra chunk with NULL result) evals('set.caption("FOO"); +plot(1:10)') ## handling warnings evals('chisq.test(mtcars$gear, mtcars$hp)') -evals(list(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', 'chisq.test(mtcars$gear, mtcars$hp)')), parse = F) -evals(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', 'chisq.test(mtcars$gear, mtcars$hp)')) +evals(list(c('chisq.test(mtcars$gear, mtcars$am)', 'pi', + 'chisq.test(mtcars$gear, mtcars$hp)')), parse = FALSE) +evals(c('chisq.test(mtcars$gear, mtcars$am)', + 'pi', + 'chisq.test(mtcars$gear, mtcars$hp)')) ## handling errors evals('runiff(20)') evals('Old MacDonald had a farm\\\\dots') evals('## Some comment') evals(c('runiff(20)', 'Old MacDonald had a farm?')) -evals(list(c('runiff(20)', 'Old MacDonald had a farm?')), parse = F) +evals(list(c('runiff(20)', 'Old MacDonald had a farm?')), parse = FALSE) evals(c('mean(1:10)', 'no.R.function()')) -evals(list(c('mean(1:10)', 'no.R.function()')), parse = F) +evals(list(c('mean(1:10)', 'no.R.function()')), parse = FALSE) evals(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')) -evals(list(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')), parse = F) +evals(list(c('no.R.object', 'no.R.function()', 'very.mixed.up(stuff)')), parse = FALSE) evals(c('no.R.object', 'Old MacDonald had a farm\\\\dots', 'pi')) -evals('no.R.object;Old MacDonald had a farm\\\\dots;pi', parse = F) -evals(list(c('no.R.object', 'Old MacDonald had a farm\\\\dots', 'pi')), parse = F) +evals('no.R.object;Old MacDonald had a farm\\\\dots;pi', parse = FALSE) +evals(list(c('no.R.object', 'Old MacDonald had a farm\\\\dots', 'pi')), parse = FALSE) ## graph options evals('plot(1:10)') evals('plot(1:10);plot(2:20)') evals('plot(1:10)', graph.output = 'jpg') evals('plot(1:10)', height = 800) -evals('plot(1:10)', height = 800, hi.res = T) -evals('plot(1:10)', graph.output = 'pdf', hi.res = T) +evals('plot(1:10)', height = 800, hi.res = TRUE) +evals('plot(1:10)', graph.output = 'pdf', hi.res = TRUE) evals('plot(1:10)', res = 30) evals('plot(1:10)', graph.name = 'myplot') evals(list('plot(1:10)', 'plot(2:20)'), graph.name = 'myplots-\%d') @@ -368,15 +373,18 @@ evals('plot(1:10)', graph.env = TRUE) evals('x <- runif(100);plot(x)', graph.env = TRUE) evals(c('plot(1:10)', 'plot(2:20)'), graph.env = TRUE) evals(c('x <- runif(100)', 'plot(x)','y <- runif(100)', 'plot(y)'), graph.env = TRUE) -evals(list(c('x <- runif(100)', 'plot(x)'), c('y <- runif(100)', 'plot(y)')), graph.env = TRUE, parse = F) +evals(list( + c('x <- runif(100)', 'plot(x)'), + c('y <- runif(100)', 'plot(y)')), + graph.env = TRUE, parse = FALSE) evals('plot(1:10)', graph.recordplot = TRUE) ## unprinted lattice plot evals('histogram(mtcars$hp)', graph.recordplot = TRUE) ## caching system.time(evals('plot(mtcars)')) -system.time(evals('plot(mtcars)')) # running again to see the speed-up :) -system.time(evals('plot(mtcars)', cache = FALSE)) # cache disabled +system.time(evals('plot(mtcars)')) # running again to see the speed-up :) +system.time(evals('plot(mtcars)', cache = FALSE)) # cache disabled ## caching mechanism does check what's inside a variable: x <- mtcars @@ -387,12 +395,13 @@ x <- mtcars system.time(evals('plot(x)')) ## stress your CPU - only once! -evals('x <- sapply(rep(mtcars$hp, 1e3), mean)') # run it again! +evals('x <- sapply(rep(mtcars$hp, 1e3), mean)') # run it again! ## play with cache require(lattice) evals('histogram(rep(mtcars$hp, 1e5))') -## nor run the below call - which would return the cached version of the above call :) +## nor run the below call +## that would return the cached version of the above call :) f <- histogram g <- rep A <- mtcars$hp @@ -422,9 +431,11 @@ evals('22/7', hooks = list('numeric' = round)) evals('matrix(runif(25), 5, 5)', hooks = list('matrix' = round)) ## setting default hook -evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), hooks = list('default'=round)) +evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), + hooks = list('default'=round)) ## round all values except for matrices -evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), hooks = list(matrix = 'print', 'default' = round)) +evals(c('runif(10)', 'matrix(runif(9), 3, 3)'), + hooks = list(matrix = 'print', 'default' = round)) # advanced hooks hooks <- list('numeric' = list(round, 2), 'matrix' = list(round, 1)) @@ -442,11 +453,14 @@ evals('runif(10)', length = 5) # note the following will not be filtered! evals('matrix(1,1,1)', length = 1) -# if you do not want to let such things be eval-ed in the middle of a string use it with other filters :) +# if you do not want to let such things be eval-ed in the middle of a string +# use it with other filters :) evals('matrix(1,1,1)', length = 1, classes = 'numeric') # hooks & filtering -evals('matrix(5,5,5)', hooks = list('matrix' = pander.return), output = 'result') +evals('matrix(5,5,5)', + hooks = list('matrix' = pander.return), + output = 'result') # eval-ing chunks in given environment myenv <- new.env() diff --git a/man/pandoc.list.return.Rd b/man/pandoc.list.return.Rd index 0384b846..e9fabf70 100644 --- a/man/pandoc.list.return.Rd +++ b/man/pandoc.list.return.Rd @@ -41,7 +41,10 @@ pandoc.list(letters[1:5], 'roman') pandoc.list(letters[1:5], loose = TRUE) ## nested lists -l <- list("First list element", rep.int('sub element', 5), "Second element", list('F', 'B', 'I', c('phone', 'pad', 'talics'))) +l <- list("First list element", + rep.int('sub element', 5), + "Second element", + list('F', 'B', 'I', c('phone', 'pad', 'talics'))) pandoc.list(l) pandoc.list(l, loose = TRUE) pandoc.list(l, 'roman') diff --git a/man/pandoc.table.return.Rd b/man/pandoc.table.return.Rd index f7d70312..617fb79e 100644 --- a/man/pandoc.table.return.Rd +++ b/man/pandoc.table.return.Rd @@ -121,7 +121,9 @@ pandoc.table(table(mtcars$am, mtcars$gear)) pandoc.table(table(state.division, state.region)) pandoc.table(table(state.division, state.region), justify = 'centre') -m <- data.frame(a=c(1, -500, 10320, 23, 77), b=runif(5), c=c('a', 'bb', 'ccc', 'dddd', 'eeeee')) +m <- data.frame(a = c(1, -500, 10320, 23, 77), + b = runif(5), + c = c('a', 'bb', 'ccc', 'dddd', 'eeeee')) pandoc.table(m) pandoc.table(m, justify = c('right', 'left', 'centre')) @@ -130,7 +132,8 @@ pandoc.table(mtcars) pandoc.table(mtcars, caption = 'Only once after the first part!') ## tables with line breaks in cells -## Note: line breaks are removed from table content and added automatically based on "split.cells" parameter! +## NOTE: line breaks are removed from table content +## and added automatically based on "split.cells" parameter! t <- data.frame(a = c('hundreds\\nof\\nmouses', '3 cats'), b=c('FOO is nice', 'BAR\\nBAR2')) pandoc.table(t) pandoc.table(t, split.cells = 5) @@ -142,7 +145,8 @@ pandoc.table(m, style = "simple") pandoc.table(t, style = "grid") pandoc.table(t, style = "grid", split.cells = 5) pandoc.table(t, style = "simple") -tryCatch(pandoc.table(t, style = "simple", split.cells = 5), error = function(e) 'Yeah, no newline support in simple tables') +tryCatch(pandoc.table(t, style = "simple", split.cells = 5), + error = function(e) 'Yeah, no newline support in simple tables') pandoc.table(t, style = "rmarkdown") ## highlight cells