15

There is a way to add R code to Markdown (Rmd) by using

```{r}
foo()
```

The result will be shown as a block of code and the output of that code (that will be calculated dynamically).

Can the same thing be done for Python or for that matter any other language?

2
  • What do you mean by "add embedded Python code"? Do you want the code to actually be executed? Or just formatted correctly and included in the HTML? Commented Apr 30, 2014 at 22:12
  • 1
    I want to execute the code. I added the word 'execute' to the question, thanks for pointing it out. Commented May 2, 2014 at 9:56

3 Answers 3

17

you can simply use:

```python 
your_code = do_some_stuff
```

And yes, you can do the same for a long list of languages. You can check the list of languages supported in this link: https://rdmd.readme.io/docs/code-blocks

Sign up to request clarification or add additional context in comments.

Comments

3

you can embed python into .Rmd as well, see https://github.com/yihui/knitr-examples/blob/master/023-engine-python.Rmd for examples

Comments

2

marky is Markdown preprocessor allowing to execute embedded python code in Markdown documents. Documents are rendered in pdf and html using pandoc. All steps are implemented in a Makefile.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.