[R] source() fails in same directory as script: cannot find file

Ista Zahn
2018-10-26T18:54:12Z

On Fri, Oct 26, 2018 at 2:16 PM Rich Shepard <rshepard at appl-ecosys.com>
wrote:
>
> On Fri, 26 Oct 2018, Ista Zahn wrote:
>
> > I'm confused. It seems the error is that the file can't be
found; if
> > so, what does it matter what is in the file?
>
> Ista,
>
>    Beats me.
>
> > As far as I can see you are either not in the directory you think you
> > are, or b) the file is not named what you think it is.
>
>    Yes, the error seems that R cannot find the file, but it's in the
same
> directory and the file does exist:
>
> > getwd()
> [1]
"/home/rshepard/documents/white-papers/geochemistry/willamette-river-mercury/scripts"
>
> ~/documents/white-papers/geochemistry/willamette-river-mercury/scripts]$ ls
input-summerize.R
> input-summerize.R
>
>    So, R is running in the scripts/ directory and the script is there, too.

No, the script is _not_ there. Compare your code:

> source('input-summarize.R')

to the contents of the directory:

> input-summerize.R

The moral of the story is, use tab-completion or copy/paste.

Best,
Ista

>
>    This is why I asked for help as the error makes no sense to me.
>
> Regards,
>
> Rich
>
> ______________________________________________
> 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.