Giter VIP home page Giter VIP logo

Comments (5)

yihui avatar yihui commented on June 14, 2024

Please take a closer look at that example. In particular, I only have one argument in knit_child(). Note you have to use the latest version of knitr as well.

from knitr-examples.

hugokoopmans avatar hugokoopmans commented on June 14, 2024

Hi Yihui, I did take a closer look and found the following:
Without externalizig the R code the md example works ok.

I can run the example and gives me expected results in markdown.

But if i externalize te R code and read it with 'read_chunk' results are like:

Collect results from the template for each i and write them back later.

read_chunk("020-for-loop-run-all.R")
\section{Now i is \Sexpr{i}}

<<>>= print(i) iris[i, ] @

\section{Now i is \Sexpr{i}}

<<>>= print(i) iris[i, ] @

\section{Now i is \Sexpr{i}}

<<>>= print(i) iris[i, ] @

These seem Latex like to me?
Does knitr_child do latex by default?

Please advise.

from knitr-examples.

yihui avatar yihui commented on June 14, 2024

No, knit_child() simply follows the syntax of the parent document. It does not use LaTeX by default.

If you want to use Markdown, you should use Markdown for both the parent document and the template. You are not supposed to use the Rnw/LaTeX syntax <<>>=.

I have no idea about your 020-for-loop-run-all.R. Please post a complete example if possible.

from knitr-examples.

hugokoopmans avatar hugokoopmans commented on June 14, 2024

Hi Yihui,

thank you for your time, indeed the issue was that in the externalized R script I forgot to replace the Rnw with the Rmd. Now I added two chunks one for latex and one for markdown and all works well.
Sorry for my sloppyness, I should have seen this before posting.

hugo

## @knitr run-all-lx
out = NULL
for (i in 1:3) {
  out = c(out, knit_child('020-for-template.Rnw'))
}

## @knitr run-all-md
out = NULL
for (i in 1:3) {
  out = c(out, knit_child('020-for-template.Rmd'))
}

from knitr-examples.

yihui avatar yihui commented on June 14, 2024

No problem.

from knitr-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.