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

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Rich Shepard
   I'm not seeing my error even after reading ?source and a couple of web
fora threads. Running R-3.5.1 on Slackware-14.2.

   The scripts/ directory has the file 'input-summarize.R' with these lines:

sites <- read.table('../data/stations.dat', header=T, sep=',', stringsAsFactors=T)
sink('../analyses/location-summaries.txt')
print(summary(sites)
sink(NULL)

hg_conc <- read.table('../data/concentrations.dat', header=T, sep=',', stringsAsFactors=T)
hg_conc$sampdate <- as.Date(as.character(hg_conc$sampdate))
sink('../analyses/concentration-summaries.txt')
print(summary(hg_conc)
sink(NULL)

   Sourcing the script within the same directory (confirmed using getwd())
fails with this error message:

> source('input-summarize.R')
Error in file(filename, "r", encoding = encoding) :
   cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
   cannot open file 'input-summarize.R': No such file or directory

   I've used this same syntax to source scripts within the past month and
would like to understand this error so I can fix it now and avoid it in the
future.

TIA,

Rich

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Ista Zahn
Hi Rich,

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?

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.

Best,
Ista
On Fri, Oct 26, 2018 at 12:30 PM Rich Shepard <[hidden email]> wrote:

>
>    I'm not seeing my error even after reading ?source and a couple of web
> fora threads. Running R-3.5.1 on Slackware-14.2.
>
>    The scripts/ directory has the file 'input-summarize.R' with these lines:
>
> sites <- read.table('../data/stations.dat', header=T, sep=',', stringsAsFactors=T)
> sink('../analyses/location-summaries.txt')
> print(summary(sites)
> sink(NULL)
>
> hg_conc <- read.table('../data/concentrations.dat', header=T, sep=',', stringsAsFactors=T)
> hg_conc$sampdate <- as.Date(as.character(hg_conc$sampdate))
> sink('../analyses/concentration-summaries.txt')
> print(summary(hg_conc)
> sink(NULL)
>
>    Sourcing the script within the same directory (confirmed using getwd())
> fails with this error message:
>
> > source('input-summarize.R')
> Error in file(filename, "r", encoding = encoding) :
>    cannot open the connection
> In addition: Warning message:
> In file(filename, "r", encoding = encoding) :
>    cannot open file 'input-summarize.R': No such file or directory
>
>    I've used this same syntax to source scripts within the past month and
> would like to understand this error so I can fix it now and avoid it in the
> future.
>
> TIA,
>
> Rich
>
> ______________________________________________
> [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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Rich Shepard
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.

   This is why I asked for help as the error makes no sense to me.

Regards,

Rich

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Ista Zahn
On Fri, Oct 26, 2018 at 2:16 PM Rich Shepard <[hidden email]> 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
>
> ______________________________________________
> [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.
Reply | Threaded
Open this post in threaded view
|

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

Rich Shepard
On Fri, 26 Oct 2018, Ista Zahn wrote:

> 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.

Ista,

   Thanks for catching the typo that I kept misssing. I mis-named the script
and didn't see that on the emacs buffer frame.

Best regards,

Rich

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Jeremie Juste
In reply to this post by Rich Shepard
Hello,

I suspect the error is in the file input-summerize.R.

I creating a new file input-summerize2.R with only print("hello") for
instance and check if

> setwd("~/documents/white-papers/geochemistry/willamette-river-mercury/scripts")
> source("input-summerize2.R")

works

Hope it helps,

Jeremie


Rich Shepard <[hidden email]> writes:

> 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.
>
>   This is why I asked for help as the error makes no sense to me.
>
> Regards,
>
> Rich
>
> ______________________________________________
> [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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Jeff Newmiller
I haven't seen mention of what OS or filesystem types are involved, but it superficially looks like it might be one of those cases where the filesystem is case-sensitive... check that all your directory and file names are capitalized correctly.

On October 26, 2018 1:11:19 PM PDT, Jeremie Juste <[hidden email]> wrote:

>Hello,
>
>I suspect the error is in the file input-summerize.R.
>
>I creating a new file input-summerize2.R with only print("hello") for
>instance and check if
>
>>
>setwd("~/documents/white-papers/geochemistry/willamette-river-mercury/scripts")
>> source("input-summerize2.R")
>
>works
>
>Hope it helps,
>
>Jeremie
>
>
>Rich Shepard <[hidden email]> writes:
>
>> 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.
>>
>>   This is why I asked for help as the error makes no sense to me.
>>
>> Regards,
>>
>> Rich
>>
>> ______________________________________________
>> [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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Ista Zahn
On Fri, Oct 26, 2018 at 10:42 PM Jeff Newmiller
<[hidden email]> wrote:
>
> I haven't seen mention of what OS or filesystem types are involved, but it superficially looks like it might be one of those cases where the filesystem is case-sensitive... check that all your directory and file names are capitalized correctly.

Just out of curiosity -- are my messages to r-help not going through?
I correctly diagnosed the problem as a simple typo in my message on
Oct 26 at 2:54 PM, but then the discussion just continued as if that
never happened.

>
> On October 26, 2018 1:11:19 PM PDT, Jeremie Juste <[hidden email]> wrote:
> >Hello,
> >
> >I suspect the error is in the file input-summerize.R.
> >
> >I creating a new file input-summerize2.R with only print("hello") for
> >instance and check if
> >
> >>
> >setwd("~/documents/white-papers/geochemistry/willamette-river-mercury/scripts")
> >> source("input-summerize2.R")
> >
> >works
> >
> >Hope it helps,
> >
> >Jeremie
> >
> >
> >Rich Shepard <[hidden email]> writes:
> >
> >> 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.
> >>
> >>   This is why I asked for help as the error makes no sense to me.
> >>
> >> Regards,
> >>
> >> Rich
> >>
> >> ______________________________________________
> >> [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.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> ______________________________________________
> [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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Bert Gunter-2
Your messages got through fine (to me, anyway). I suspect people are just
failing to read through the threads.

-- Bert

On Sat, Oct 27, 2018 at 6:35 AM Ista Zahn <[hidden email]> wrote:

> On Fri, Oct 26, 2018 at 10:42 PM Jeff Newmiller
> <[hidden email]> wrote:
> >
> > I haven't seen mention of what OS or filesystem types are involved, but
> it superficially looks like it might be one of those cases where the
> filesystem is case-sensitive... check that all your directory and file
> names are capitalized correctly.
>
> Just out of curiosity -- are my messages to r-help not going through?
> I correctly diagnosed the problem as a simple typo in my message on
> Oct 26 at 2:54 PM, but then the discussion just continued as if that
> never happened.
>
> >
> > On October 26, 2018 1:11:19 PM PDT, Jeremie Juste <
> [hidden email]> wrote:
> > >Hello,
> > >
> > >I suspect the error is in the file input-summerize.R.
> > >
> > >I creating a new file input-summerize2.R with only print("hello") for
> > >instance and check if
> > >
> > >>
> >
> >setwd("~/documents/white-papers/geochemistry/willamette-river-mercury/scripts")
> > >> source("input-summerize2.R")
> > >
> > >works
> > >
> > >Hope it helps,
> > >
> > >Jeremie
> > >
> > >
> > >Rich Shepard <[hidden email]> writes:
> > >
> > >> 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.
> > >>
> > >>   This is why I asked for help as the error makes no sense to me.
> > >>
> > >> Regards,
> > >>
> > >> Rich
> > >>
> > >> ______________________________________________
> > >> [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.
> >
> > --
> > Sent from my phone. Please excuse my brevity.
> >
> > ______________________________________________
> > [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.
>

        [[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Rich Shepard
In reply to this post by Ista Zahn
On Sat, 27 Oct 2018, Ista Zahn wrote:

> Just out of curiosity -- are my messages to r-help not going through? I
> correctly diagnosed the problem as a simple typo in my message on Oct 26
> at 2:54 PM, but then the discussion just continued as if that never
> happened.

   I responded to you and Jeff (his off the list), and saw my response to you
yesterday.

   Since you found the typo I keep missing, and I fixed it, I deleted the
thread here.

Rich

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Rich Shepard
On Sat, 27 Oct 2018, Rich Shepard wrote:

> thread here.

   'Here' meaning on alpine on my workstation, not on the mail list.

Rich

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Duncan Murdoch-2
In reply to this post by Ista Zahn
On 27/10/2018 9:35 AM, Ista Zahn wrote:
> On Fri, Oct 26, 2018 at 10:42 PM Jeff Newmiller
> <[hidden email]> wrote:
>>
>> I haven't seen mention of what OS or filesystem types are involved, but it superficially looks like it might be one of those cases where the filesystem is case-sensitive... check that all your directory and file names are capitalized correctly.
>
> Just out of curiosity -- are my messages to r-help not going through?
> I correctly diagnosed the problem as a simple typo in my message on
> Oct 26 at 2:54 PM, but then the discussion just continued as if that
> never happened.

I saw it.  I don't know why others didn't....

Duncan Murdoch

>
>>
>> On October 26, 2018 1:11:19 PM PDT, Jeremie Juste <[hidden email]> wrote:
>>> Hello,
>>>
>>> I suspect the error is in the file input-summerize.R.
>>>
>>> I creating a new file input-summerize2.R with only print("hello") for
>>> instance and check if
>>>
>>>>
>>> setwd("~/documents/white-papers/geochemistry/willamette-river-mercury/scripts")
>>>> source("input-summerize2.R")
>>>
>>> works
>>>
>>> Hope it helps,
>>>
>>> Jeremie
>>>
>>>
>>> Rich Shepard <[hidden email]> writes:
>>>
>>>> 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.
>>>>
>>>>    This is why I asked for help as the error makes no sense to me.
>>>>
>>>> Regards,
>>>>
>>>> Rich
>>>>
>>>> ______________________________________________
>>>> [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.
>>
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> ______________________________________________
>> [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.
>

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Jeff Newmiller
FWIW the diagnosis of misspelling appeared, ah, miraculous as the OP appeared consistent in using the incorrect spelling and the diagnosis was not confirmed by the OP.

On October 27, 2018 1:38:40 PM PDT, Duncan Murdoch <[hidden email]> wrote:

>On 27/10/2018 9:35 AM, Ista Zahn wrote:
>> On Fri, Oct 26, 2018 at 10:42 PM Jeff Newmiller
>> <[hidden email]> wrote:
>>>
>>> I haven't seen mention of what OS or filesystem types are involved,
>but it superficially looks like it might be one of those cases where
>the filesystem is case-sensitive... check that all your directory and
>file names are capitalized correctly.
>>
>> Just out of curiosity -- are my messages to r-help not going through?
>> I correctly diagnosed the problem as a simple typo in my message on
>> Oct 26 at 2:54 PM, but then the discussion just continued as if that
>> never happened.
>
>I saw it.  I don't know why others didn't....
>
>Duncan Murdoch
>
>>
>>>
>>> On October 26, 2018 1:11:19 PM PDT, Jeremie Juste
><[hidden email]> wrote:
>>>> Hello,
>>>>
>>>> I suspect the error is in the file input-summerize.R.
>>>>
>>>> I creating a new file input-summerize2.R with only print("hello")
>for
>>>> instance and check if
>>>>
>>>>>
>>>>
>setwd("~/documents/white-papers/geochemistry/willamette-river-mercury/scripts")
>>>>> source("input-summerize2.R")
>>>>
>>>> works
>>>>
>>>> Hope it helps,
>>>>
>>>> Jeremie
>>>>
>>>>
>>>> Rich Shepard <[hidden email]> writes:
>>>>
>>>>> 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.
>>>>>
>>>>>    This is why I asked for help as the error makes no sense to me.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Rich
>>>>>
>>>>> ______________________________________________
>>>>> [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.
>>>
>>> --
>>> Sent from my phone. Please excuse my brevity.
>>>
>>> ______________________________________________
>>> [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.
>>

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Rich Shepard
On Sat, 27 Oct 2018, Jeff Newmiller wrote:

> FWIW the diagnosis of misspelling appeared, ah, miraculous as the OP
> appeared consistent in using the incorrect spelling and the diagnosis was
> not confirmed by the OP.

From [hidden email] Fri Oct 26 12:46:22 2018
Date: Fri, 26 Oct 2018 12:46:22 -0700 (PDT)
From: Rich Shepard <[hidden email]>
To: [hidden email]
Subject: Re: [R] source() fails in same directory as script: cannot find file [FIXED]

On Fri, 26 Oct 2018, Ista Zahn wrote:

> 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.

Ista,

    Thanks for catching the typo that I kept misssing. I mis-named the script
and didn't see that on the emacs buffer frame.

Best regards,

Rich

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: source() fails in same directory as script: cannot find file

Ista Zahn
In reply to this post by Jeff Newmiller
On Sat, Oct 27, 2018 at 4:57 PM Jeff Newmiller <[hidden email]> wrote:
>
> FWIW the diagnosis of misspelling appeared, ah, miraculous as the OP appeared consistent in using the incorrect spelling and the diagnosis was not confirmed by the OP.

I am of course happy to be seen as Miracle Worker, but I assure you I
solved the mystery without recourse to any information beyond what was
publicly posted on the r-help mailing list.

--Ista

>
> On October 27, 2018 1:38:40 PM PDT, Duncan Murdoch <[hidden email]> wrote:
> >On 27/10/2018 9:35 AM, Ista Zahn wrote:
> >> On Fri, Oct 26, 2018 at 10:42 PM Jeff Newmiller
> >> <[hidden email]> wrote:
> >>>
> >>> I haven't seen mention of what OS or filesystem types are involved,
> >but it superficially looks like it might be one of those cases where
> >the filesystem is case-sensitive... check that all your directory and
> >file names are capitalized correctly.
> >>
> >> Just out of curiosity -- are my messages to r-help not going through?
> >> I correctly diagnosed the problem as a simple typo in my message on
> >> Oct 26 at 2:54 PM, but then the discussion just continued as if that
> >> never happened.
> >
> >I saw it.  I don't know why others didn't....
> >
> >Duncan Murdoch
> >
> >>
> >>>
> >>> On October 26, 2018 1:11:19 PM PDT, Jeremie Juste
> ><[hidden email]> wrote:
> >>>> Hello,
> >>>>
> >>>> I suspect the error is in the file input-summerize.R.
> >>>>
> >>>> I creating a new file input-summerize2.R with only print("hello")
> >for
> >>>> instance and check if
> >>>>
> >>>>>
> >>>>
> >setwd("~/documents/white-papers/geochemistry/willamette-river-mercury/scripts")
> >>>>> source("input-summerize2.R")
> >>>>
> >>>> works
> >>>>
> >>>> Hope it helps,
> >>>>
> >>>> Jeremie
> >>>>
> >>>>
> >>>> Rich Shepard <[hidden email]> writes:
> >>>>
> >>>>> 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.
> >>>>>
> >>>>>    This is why I asked for help as the error makes no sense to me.
> >>>>>
> >>>>> Regards,
> >>>>>
> >>>>> Rich
> >>>>>
> >>>>> ______________________________________________
> >>>>> [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.
> >>>
> >>> --
> >>> Sent from my phone. Please excuse my brevity.
> >>>
> >>> ______________________________________________
> >>> [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.
> >>
>
> --
> Sent from my phone. Please excuse my brevity.

______________________________________________
[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.