Paths in knitr

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Paths in knitr

G.Maubach
Hi All,

I have to compile a report for the management and decided to use RMarkdown
and knitr. I compiled all needed plots (using separate R scripts) before
compiling the report, thus all plots reside in my graphics directory. The
RMarkdown report needs to access these files. I have defined

```{r setup, include = FALSE}
knitr::opts_knit$set(
  echo = FALSE,
  xtable.type = "html",
  base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
  root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
  fig.path = "results/graphics")  # relative path required, see
http://yihui.name/knitr/options
```

and then referenced my plot using

<img src = "email_distribution_pie.png"></img>

because I want to be able to customize the plotting attributes.

But that fails with the message "pandoc.exe: Could not fetch
email_distribution_pie.png".

If I give it the absolute path
"H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/graphics/email_distribution_pie.png"
it works fine as well if I copy the plot into the directory where the
report.RMD file resides.

How can I tell knitr to fetch the ready-made plots from the graphics
directory?

Kind regards

Georg

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Paths in knitr

Yihui Xie-2
Why do you have to set the base.dir option?

Regards,
Yihui
--
https://yihui.name


On Thu, Jun 8, 2017 at 6:15 AM,  <[hidden email]> wrote:

> Hi All,
>
> I have to compile a report for the management and decided to use RMarkdown
> and knitr. I compiled all needed plots (using separate R scripts) before
> compiling the report, thus all plots reside in my graphics directory. The
> RMarkdown report needs to access these files. I have defined
>
> ```{r setup, include = FALSE}
> knitr::opts_knit$set(
>   echo = FALSE,
>   xtable.type = "html",
>   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>   fig.path = "results/graphics")  # relative path required, see
> http://yihui.name/knitr/options
> ```
>
> and then referenced my plot using
>
> <img src = "email_distribution_pie.png"></img>
>
> because I want to be able to customize the plotting attributes.
>
> But that fails with the message "pandoc.exe: Could not fetch
> email_distribution_pie.png".
>
> If I give it the absolute path
> "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/graphics/email_distribution_pie.png"
> it works fine as well if I copy the plot into the directory where the
> report.RMD file resides.
>
> How can I tell knitr to fetch the ready-made plots from the graphics
> directory?
>
> Kind regards
>
> Georg
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Paths in knitr

Duncan Murdoch-2
In reply to this post by G.Maubach
On 08/06/2017 7:15 AM, [hidden email] wrote:

> Hi All,
>
> I have to compile a report for the management and decided to use RMarkdown
> and knitr. I compiled all needed plots (using separate R scripts) before
> compiling the report, thus all plots reside in my graphics directory. The
> RMarkdown report needs to access these files. I have defined
>
> ```{r setup, include = FALSE}
> knitr::opts_knit$set(
>   echo = FALSE,
>   xtable.type = "html",
>   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>   fig.path = "results/graphics")  # relative path required, see
> http://yihui.name/knitr/options
> ```
>
> and then referenced my plot using
>
> <img src = "email_distribution_pie.png"></img>
>
> because I want to be able to customize the plotting attributes.
>
> But that fails with the message "pandoc.exe: Could not fetch
> email_distribution_pie.png".
>
> If I give it the absolute path
> "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/graphics/email_distribution_pie.png"
> it works fine as well if I copy the plot into the directory where the
> report.RMD file resides.
>
> How can I tell knitr to fetch the ready-made plots from the graphics
> directory?

Put the path in a variable, and use that in the img tag, e.g.

```{r}
gdir <- file.path(knitr::opts_knit$get("base.dir"), "graphics")
```

<img src = `r file.path(gdir, "email_distribution_pie.png")`></img>

If you think that is still too much typing, you could make a little
function to turn a string like "email_distribution_pie" into the fully
specified path.

HOWEVER:  Your workflow may not be ideal.  It is almost always better to
produce the graphs in code that's in the document, rather than in
separate R scripts.   This makes it *much* easier to modify the plots
and be sure that the latest version makes it into the report.

If the plots require lots of code and you think it would be distracting
in the source of your document, then it's time to make a private
package, and put the code in there.  In the document, just include calls
to functions from that package.

Duncan Murdoch

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Paths in knitr

Yihui Xie-2
In reply to this post by Yihui Xie-2
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, <[hidden email]> wrote:

> Hi Yi,
>
> many thanks for your reply.
>
> Why I do have to se the base.dir option? Cause, to me it is not clear from
> the documentation, where knitr looks for data files and how I can adjust
> knitr to tell it where to look. base.dir was a try, but did not work.
>
> Can you give me a hint where I can find information/documentation on this
> path issue?
>
> Kind regards
>
> Georg
>
>
> > Gesendet: Donnerstag, 08. Juni 2017 um 15:05 Uhr
> > Von: "Yihui Xie" <[hidden email]>
> > An: [hidden email]
> > Cc: "R Help" <[hidden email]>
> > Betreff: Re: [R] Paths in knitr
> >
> > Why do you have to set the base.dir option?
> >
> > Regards,
> > Yihui
> > --
> > https://yihui.name
> >
> >
> > On Thu, Jun 8, 2017 at 6:15 AM,  <[hidden email]> wrote:
> > > Hi All,
> > >
> > > I have to compile a report for the management and decided to use
> RMarkdown
> > > and knitr. I compiled all needed plots (using separate R scripts)
> before
> > > compiling the report, thus all plots reside in my graphics directory.
> The
> > > RMarkdown report needs to access these files. I have defined
> > >
> > > ```{r setup, include = FALSE}
> > > knitr::opts_knit$set(
> > >   echo = FALSE,
> > >   xtable.type = "html",
> > >   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
> > >   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
> > >   fig.path = "results/graphics")  # relative path required, see
> > > http://yihui.name/knitr/options
> > > ```
> > >
> > > and then referenced my plot using
> > >
> > > <img src = "email_distribution_pie.png"></img>
> > >
> > > because I want to be able to customize the plotting attributes.
> > >
> > > But that fails with the message "pandoc.exe: Could not fetch
> > > email_distribution_pie.png".
> > >
> > > If I give it the absolute path
> > > "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/
> graphics/email_distribution_pie.png"
> > > it works fine as well if I copy the plot into the directory where the
> > > report.RMD file resides.
> > >
> > > How can I tell knitr to fetch the ready-made plots from the graphics
> > > directory?
> > >
> > > Kind regards
> > >
> > > Georg
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Paths in knitr

G.Maubach
In reply to this post by G.Maubach
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

From that description I thought, if the base.dir can be used for writng
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 <[hidden email]>
An:     [hidden email],
Kopie:  R Help <[hidden email]>
Datum:  09.06.2017 20:53
Betreff:        Re: [R] Paths in knitr
Gesendet von:   "R-help" <[hidden email]>



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, <[hidden email]> wrote:

> Hi Yi,
>
> many thanks for your reply.
>
> Why I do have to se the base.dir option? Cause, to me it is not clear
from
> the documentation, where knitr looks for data files and how I can adjust
> knitr to tell it where to look. base.dir was a try, but did not work.
>
> Can you give me a hint where I can find information/documentation on
this

> path issue?
>
> Kind regards
>
> Georg
>
>
> > Gesendet: Donnerstag, 08. Juni 2017 um 15:05 Uhr
> > Von: "Yihui Xie" <[hidden email]>
> > An: [hidden email]
> > Cc: "R Help" <[hidden email]>
> > Betreff: Re: [R] Paths in knitr
> >
> > Why do you have to set the base.dir option?
> >
> > Regards,
> > Yihui
> > --
> > https://yihui.name
> >
> >
> > On Thu, Jun 8, 2017 at 6:15 AM,  <[hidden email]> wrote:
> > > Hi All,
> > >
> > > I have to compile a report for the management and decided to use
> RMarkdown
> > > and knitr. I compiled all needed plots (using separate R scripts)
> before
> > > compiling the report, thus all plots reside in my graphics
directory.

> The
> > > RMarkdown report needs to access these files. I have defined
> > >
> > > ```{r setup, include = FALSE}
> > > knitr::opts_knit$set(
> > >   echo = FALSE,
> > >   xtable.type = "html",
> > >   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
> > >   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
> > >   fig.path = "results/graphics")  # relative path required, see
> > > http://yihui.name/knitr/options
> > > ```
> > >
> > > and then referenced my plot using
> > >
> > > <img src = "email_distribution_pie.png"></img>
> > >
> > > because I want to be able to customize the plotting attributes.
> > >
> > > But that fails with the message "pandoc.exe: Could not fetch
> > > email_distribution_pie.png".
> > >
> > > If I give it the absolute path
> > > "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/
> graphics/email_distribution_pie.png"
> > > it works fine as well if I copy the plot into the directory where
the
> > > report.RMD file resides.
> > >
> > > How can I tell knitr to fetch the ready-made plots from the graphics
> > > directory?
> > >
> > > Kind regards
> > >
> > > Georg
>

                 [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Paths in knitr

Yihui Xie-2
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,  <[hidden email]> wrote:

> 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
>
> From that description I thought, if the base.dir can be used for writng
> 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 <[hidden email]>
> An:     [hidden email],
> Kopie:  R Help <[hidden email]>
> Datum:  09.06.2017 20:53
> Betreff:        Re: [R] Paths in knitr
> Gesendet von:   "R-help" <[hidden email]>
>
>
>
> 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, <[hidden email]> wrote:
>
>> Hi Yi,
>>
>> many thanks for your reply.
>>
>> Why I do have to se the base.dir option? Cause, to me it is not clear
> from
>> the documentation, where knitr looks for data files and how I can adjust
>> knitr to tell it where to look. base.dir was a try, but did not work.
>>
>> Can you give me a hint where I can find information/documentation on
> this
>> path issue?
>>
>> Kind regards
>>
>> Georg
>>
>>
>> > Gesendet: Donnerstag, 08. Juni 2017 um 15:05 Uhr
>> > Von: "Yihui Xie" <[hidden email]>
>> > An: [hidden email]
>> > Cc: "R Help" <[hidden email]>
>> > Betreff: Re: [R] Paths in knitr
>> >
>> > Why do you have to set the base.dir option?
>> >
>> > Regards,
>> > Yihui
>> > --
>> > https://yihui.name
>> >
>> >
>> > On Thu, Jun 8, 2017 at 6:15 AM,  <[hidden email]> wrote:
>> > > Hi All,
>> > >
>> > > I have to compile a report for the management and decided to use
>> RMarkdown
>> > > and knitr. I compiled all needed plots (using separate R scripts)
>> before
>> > > compiling the report, thus all plots reside in my graphics
> directory.
>> The
>> > > RMarkdown report needs to access these files. I have defined
>> > >
>> > > ```{r setup, include = FALSE}
>> > > knitr::opts_knit$set(
>> > >   echo = FALSE,
>> > >   xtable.type = "html",
>> > >   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>> > >   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>> > >   fig.path = "results/graphics")  # relative path required, see
>> > > http://yihui.name/knitr/options
>> > > ```
>> > >
>> > > and then referenced my plot using
>> > >
>> > > <img src = "email_distribution_pie.png"></img>
>> > >
>> > > because I want to be able to customize the plotting attributes.
>> > >
>> > > But that fails with the message "pandoc.exe: Could not fetch
>> > > email_distribution_pie.png".
>> > >
>> > > If I give it the absolute path
>> > > "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/
>> graphics/email_distribution_pie.png"
>> > > it works fine as well if I copy the plot into the directory where
> the
>> > > report.RMD file resides.
>> > >
>> > > How can I tell knitr to fetch the ready-made plots from the graphics
>> > > directory?
>> > >
>> > > Kind regards
>> > >
>> > > Georg
>>
>
>                  [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Antwort: Re: Re: Paths in knitr

G.Maubach
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 <[hidden email]>
An:     [hidden email],
Kopie:  Duncan Murdoch <[hidden email]>, R Help
<[hidden email]>
Datum:  12.06.2017 18:29
Betreff:        Re: Re: [R] Paths in knitr
Gesendet von:   [hidden email]



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,  <[hidden email]> wrote:
> 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
>
> From that description I thought, if the base.dir can be used for writng
> 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 <[hidden email]>
> An:     [hidden email],
> Kopie:  R Help <[hidden email]>
> Datum:  09.06.2017 20:53
> Betreff:        Re: [R] Paths in knitr
> Gesendet von:   "R-help" <[hidden email]>
>
>
>
> 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, <[hidden email]> wrote:
>
>> Hi Yi,
>>
>> many thanks for your reply.
>>
>> Why I do have to se the base.dir option? Cause, to me it is not clear
> from
>> the documentation, where knitr looks for data files and how I can
adjust

>> knitr to tell it where to look. base.dir was a try, but did not work.
>>
>> Can you give me a hint where I can find information/documentation on
> this
>> path issue?
>>
>> Kind regards
>>
>> Georg
>>
>>
>> > Gesendet: Donnerstag, 08. Juni 2017 um 15:05 Uhr
>> > Von: "Yihui Xie" <[hidden email]>
>> > An: [hidden email]
>> > Cc: "R Help" <[hidden email]>
>> > Betreff: Re: [R] Paths in knitr
>> >
>> > Why do you have to set the base.dir option?
>> >
>> > Regards,
>> > Yihui
>> > --
>> > https://yihui.name
>> >
>> >
>> > On Thu, Jun 8, 2017 at 6:15 AM,  <[hidden email]> wrote:
>> > > Hi All,
>> > >
>> > > I have to compile a report for the management and decided to use
>> RMarkdown
>> > > and knitr. I compiled all needed plots (using separate R scripts)
>> before
>> > > compiling the report, thus all plots reside in my graphics
> directory.
>> The
>> > > RMarkdown report needs to access these files. I have defined
>> > >
>> > > ```{r setup, include = FALSE}
>> > > knitr::opts_knit$set(
>> > >   echo = FALSE,
>> > >   xtable.type = "html",
>> > >   base.dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>> > >   root_dir = "H:/2017/Analysen/Kundenzufriedenheit/Auswertung",
>> > >   fig.path = "results/graphics")  # relative path required, see
>> > > http://yihui.name/knitr/options
>> > > ```
>> > >
>> > > and then referenced my plot using
>> > >
>> > > <img src = "email_distribution_pie.png"></img>
>> > >
>> > > because I want to be able to customize the plotting attributes.
>> > >
>> > > But that fails with the message "pandoc.exe: Could not fetch
>> > > email_distribution_pie.png".
>> > >
>> > > If I give it the absolute path
>> > > "H:/2017/Analysen/Kundenzufriedenheit/Auswertung/results/
>> graphics/email_distribution_pie.png"
>> > > it works fine as well if I copy the plot into the directory where
> the
>> > > report.RMD file resides.
>> > >
>> > > How can I tell knitr to fetch the ready-made plots from the
graphics

>> > > directory?
>> > >
>> > > Kind regards
>> > >
>> > > Georg
>>
>
>                  [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Loading...