Skip to content

Paths in knitr

3 messages · Yihui Xie, G.Maubach at weinwolf.de

#
Hi Yihui,
Hi Duncan,

I corrected my typo. Unfortunately knitr did not find my plots in the 
directory where they reside which is different from the Rmd document.

The documentation of knitr says:

base.dir: (NULL) an absolute directory under which the plots are generate
root.dir: (NULL) the root directory when evaluating code chunks; if NULL, 
the directory of the input document will be used
plots, it is then also used for reading plots if set? No, it is not.
If I set the root directory to the plots/graphics directory will knitr 
then find my plots? No, it does not.

Reading blog posts my thoughts looked not so strange to me, e.g. 
https://philmikejones.wordpress.com/2015/05/20/set-root-directory-knitr/. 
Unfortunately, it does not work for me.

I am using a RStudio project file. Could it be that this interferes which 
the knitr options?

I tried the solution that Duncan suggested:

c_path_plots <- 
"H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/graphics

`r knitr::include_graphics(file.path(c_path_plots, 
"email_distribution_pie.png"))`

This solution works fine. I will go with it for this project as I have to 
finish my report soon.

I read Hadley's book on bulding R Packages (
https://www.amazon.de/R-Packages-Hadley-Wickham/dp/1491910593) and found 
it quite complicated and time consuming to build one. Thus I did not try 
yet to build my own packages. At the end of last week I heard from another 
library (http://reaktanz.de/R/pckg/roxyPackage/) which shall make building 
packages much easier. I plan to try that shortly.

On my path to become better in analytics using R, I will try to use 
modules of Rmd files which can then easily be integrated into a Rmd 
report. I have yet to see how I can include these file into a complete 
report.

Kind regards

Georg


----- Weitergeleitet von Georg Maubach/WWBO/WW/HAW am 12.06.2017 08:47 
-----

Von:    Yihui Xie <xie at yihui.name>
An:     G.Maubach at gmx.de, 
Kopie:  R Help <r-help at r-project.org>
Datum:  09.06.2017 20:53
Betreff:        Re: [R] Paths in knitr
Gesendet von:   "R-help" <r-help-bounces at r-project.org>



I'd say it is an expert-only option. If you do not understand what it
means, I strongly recommend you not to set it.

Similarly, you set the root_dir option and I don't know why you did it, 
but
it is a typo anyway (should be root.dir).

Regards,
Yihui
--
https://yihui.name
On Fri, Jun 9, 2017 at 4:50 AM, <G.Maubach at gmx.de> wrote:

            
from
this
directory.
the
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
Will there be anything wrong if you do not set these options?

Regards,
Yihui
--
https://yihui.name
On Mon, Jun 12, 2017 at 2:24 AM, <G.Maubach at weinwolf.de> wrote:
#
Hi Yihui,

I took root.dir and base.dir out. Everything works fine despite the 
change.

I have implemented the solution Duncun suggested. I have difficulties with 
the scaling / image size in my report. Some plots are too big, some are 
too small. I need to adjust any plot. Steep learning curve :)

Kind regards

Georg




Von:    Yihui Xie <xie at yihui.name>
An:     G.Maubach at weinwolf.de, 
Kopie:  Duncan Murdoch <murdoch.duncan at gmail.com>, R Help 
<r-help at r-project.org>
Datum:  12.06.2017 18:29
Betreff:        Re: Re: [R] Paths in knitr
Gesendet von:   xieyihui at gmail.com



Will there be anything wrong if you do not set these options?

Regards,
Yihui
--
https://yihui.name
On Mon, Jun 12, 2017 at 2:24 AM, <G.Maubach at weinwolf.de> wrote:
generate
NULL,
.
which
to
another
building
adjust
graphics