20 Comments
Guest *Januz* @ 2012-10-02 07:56:06 originally posted:
Hi,
thanks for this great library! I wonder how I can get Python syntax higlighting to work in LaTeX. In your examples, it seems to work, but when I copy the code into LaTeX, the output isn´t highlighted, while R code in the same document is...
Thanks,
Januz
Currently the support of syntax highlighting for LaTeX and HTML is poor, and there is no support to graphics for Python. I may add them in future versions, but I'm really weak at Python, so I do not know when this can be done.
Originally posted on 2012-10-02 15:55:15
Guest *David Forrest* @ 2012-10-26 19:50:15 originally posted:
Wouldn't one solution be to write the python code to explicitly create a
figure, then explicitly reference that figure in the markup?
Of course it can be done that way; it is just a little bit inelegant to manually save figures. Perhaps I'm spoiled by R, in which I can automatically save and insert plots.
Originally posted on 2012-10-26 20:40:29
Guest *zhanxw* @ 2013-10-17 04:11:34 originally posted:
Will this library make things easier?
https://code.google.com/p/google-code-prettify/
Thanks, but that is only for web pages. The latest version of knitr actually supports syntax highlighting for Python now (works for both LaTeX and HTML).
Originally posted on 2013-10-21 03:51:23
Guest *CJ* @ 2014-03-06 10:33:15 originally posted:
why you don't put Latex as a language engine... that's easy to use pygments to highlight it if you do this.
Guest *Januz* @ 2012-10-02 07:58:22 originally posted:
... also (sorry for double post):
Will graphical output from Python (like Matplotlib graphs) be displayed?
Thanks again,
J
Guest *David Forrest* @ 2012-10-26 19:53:48 originally posted:
Is there some way to write the code chunks into a files of their own? I.e., after you run bash.Rmd, you would have a test-bash.bash in the working directory?
Yes it is possible. You can simply purl('bash.Rmd', output = 'test-bash.bash') inside bash.Rmd.
Originally posted on 2012-10-26 20:37:28
Guest *David Forrest* @ 2012-10-26 21:29:41 originally posted:
Thanks,
That looks like it grabs all the code into one file. How would that work for just one chunk or set of chunks?
I guess I'm looking for something like the chunk-specifc feature of notangle:
For an Rnw file I found I can do this to strip out the options and selectively tangle:
sed '/<>/>>/' testAll.Rnw | notangle -Rtest-bash > test-bash.bash
It is easy to implement (should be one liner) by introducing a new chunk option like tangle=TRUE/FALSE. I just have not decided whether to do it.
Originally posted on 2012-10-27 05:07:49
Guest *David Forrest* @ 2012-10-30 20:38:33 originally posted:
Without modifying knitr, here's an R function to call a notangle command on a noweb or sweave/knitr .Rnw file:
notangle<-function(file=NULL,root='*',output=NULL){
# Clean chunk options from an Sweave/knitr file and run notangle on the result with -R to output or stdout
# assume notangle is on the system path
if (is.null(file))
stop("file not set, exiting")
commandLine<-sprintf("sed '/^<>/>>/' %s | notangle -R%s",file,root)
if (! is.null(output))
commandLine = paste(commandLine, output,sep=" > ")
system(commandLine)
}
It might be nice to add a root='*' default option to purl() and treat it like a regex on the chunknames like the -R option of notangle.
If noweb's notangle took a regex as a -R root, then it could operate on knitr or sweave files directly. Short of that, one can use a filter like the above to make .Rnw files compatible with noweb.
Guest *lei* @ 2013-07-10 01:33:05 originally posted:
Hi, Yihui - Thanks so much for knitr to support SAS although you are not really into SAS. Sometimes I need to run both SAS & R.
the problem is run the code include the scripts below, and it does created the lst, log file which are correct,
but I could not get the sas output. like proc print in pdf. I could see the scripts in the pdf file.
Could you help me with this? Thanks so much!
<<engine='sas', engine.path="C:Program FilesSASHomeSASFoundation9.3sas.exe">>=
/* write the content of your test.sas here */
@
Thanks!
Hi, please make sure the path to sas.exe is correct. I think you copied it from my example, but that does not guarantee you installed SAS to the same directory.
The better approach is to set your PATH to contain the path of sas.exe, so you do not need to use engine.path at all. To know more about PATH, see http://www.computerhope.com/issues/ch000549.htm
Originally posted on 2013-07-11 05:43:59
Guest *Paul Hurtado* @ 2015-12-15 22:38:19 originally posted:
I have a similar problem trying to use knitr to run python code in Windows 7 (through TeXstudio, not Rstudio). PATH is set correctly (I can run python.exe from the command prompt) but it acts like it can't find python (doesn't run) unless I specify engine.path=... Also, it keeps giving an error saying I need to install highlight, which was installed and added to PATH (and runs from the command prompt when I type "highlight").
Could your code need to make use of normalizePath() somewhere perhaps?
Guest *roneyfraga* @ 2014-03-04 03:19:12 originally posted:
R and Python in the same report, brilliant!
Guest *Colombo* @ 2015-07-28 00:11:17 originally posted:
Highlighting by default for other than R isn't working.
It would be nice to have it working from scratch.
Additionally, there is a little information on what "Highlight" I need to install.
Is it LaTeX package? (probably not, if it is required for markdown as well)
R package? (there is actually R package called Highlight, it is a bit confusing).
Guest *Xiuting Mi* @ 2015-09-15 07:31:45 originally posted:
Hello, I am using Rmarkdown to create html file. Now I want to embed sas codes into it, so I have following codes in my .rmd.
data _null_;
%put 'Hello, world!';
run;
I have no idea how to show the sas codes results here. Above codes can be complied without errors, but it show like a plain text without results of the codes. Could anyone help me out here?
Many thanks,
Xiuting
Guest *skohari* @ 2016-01-08 21:39:46 originally posted:
Xiuting Mi,
Since you're generating a null dataset, %put will put' the Hello world statement to the log, not to the result window; hence there is nothing generated in the html file. I'd suggest running some other simple code like proc freq` etc. to see the results. Check out this brilliant piece http://www.ssc.wisc.edu/~hemken/SASworkshops/SASWindows/Markdown/SASmarkdown.html
Guest *kungfujam* @ 2015-12-09 17:11:37 originally posted:
Is there any way to include a code chunk with another language and retain the ability to run all chunks within r studio? (Hacks fine!). It's slightly annoying to include a chunk like:
wc some_file.txt
and then not be able to use the cmd+option+r shortcut to run all chunks internally.
Unfortunately no, that is not possible at the moment. You may file a feature request to support.rstudio.com if you want.
Originally posted on 2015-12-09 23:29:12
Guest *essay services online* @ 2016-04-14 14:08:40 originally posted:
This engine looks pretty useful and helpful for those people who are fun in doing some programming stuff that might be able to give them some good help in terms of promoting a better output that they used to have.
Guest *Luca Cerone* @ 2016-08-31 16:46:23 originally posted:
Hi, I just learnt about using Python code in Rmarkdown documents which is brilliant!
I was wondering however whether it would by possible to use Python 3? If so it is as easy as writing {python3} ???
{python3} is not supported yet, but you can set engine.path='python3' in {python}.
Originally posted on 2016-09-10 03:27:04
Guest *carloslesmes* @ 2016-11-01 17:08:21 originally posted:
What about Julia?
Experiment here: https://github.com/yihui/runr
Originally posted on 2016-11-01 19:15:59
Guest *cnmade* @ 2016-12-27 02:14:52 originally posted:
How about add PHP language?
Guest *Ricardo Pérez* @ 2017-01-17 17:37:18 originally posted:
How can I use PHP language?
Guest *Renger van Nieuwkoop* @ 2017-02-06 12:04:13 originally posted:
Hi Yihui
I tried to get tikz to run on my Windows machine, but to no avail. The example of tikz pointed to in the document on the tikz-engine doesn't work. Could you provide a full example?
Renger
Guest *Edith Invernizzi* @ 2017-03-03 17:29:24 originally posted:
@yihui:disqus Can I use php as a language? Great package and very thorough explanations, by the way.
Please see yihui/knitr#1350
Originally posted on 2017-03-06 19:41:46
Guest *Antonello Lobianco* @ 2017-03-14 07:46:59 originally posted:
Any support for Julia ?
Guest *Ben Bolker* @ 2017-07-17 00:35:51 originally posted:
there is via the runr package: see https://rpubs.com/yihui/julia-knitr (you'll have to install runr from Github. I'm finding the socket-based version flaky and will probably fall back to doing it as e.g. via Python ("julia -E" might do the trick?)
Guest *Juilien Hsu* @ 2017-03-21 14:21:09 originally posted:
appreciated with this capacity created by you; will explore it for my work!!
访客 *Zhou Ji (吉州)* @ 2017-07-21 16:13:55 写道:
For something as simple as
pwd
I could not get rid of the following error. Any clue?
running command '"C:WindowsSystem32bash.exe" -c "pwd"' had status 65535
I can run this command manually from Window command line without problem.
Guest *Mert Nuhoglu* @ 2018-03-06 17:09:38 originally posted:
Is nodejs/javascript supported?
Guest *Robby* @ 2020-01-22 09:23:15 originally posted:
Umron avaero
Sign in to join the discussion
Sign in with GitHub