For what it's worth (perhaps little...), I would normally do

for (pn in pathnames) source(pn)

It's clearer to read and won't return a strange value. I doubt there will
be a noticeable difference in speed. It can easily be extended to be more
informative, as in
for (pn in pathnames) {
  cat('--- now sourcing',pn,'---\n')
  source(pn)
}

One could also introduce error trapping using try() in this version.

As far as surpassing the message is concerned, one option would be to put
your sapply() expression inside invisible(). Not sure what will happen in
that case if any of the scripts fail with an error.

> 10*2
[1] 20
> invisible(10*2)

>

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 7/29/16, 3:52 AM, "R-help on behalf of Frank S."
<r-help-boun...@r-project.org on behalf of f_j_...@hotmail.com> wrote:

>Dear list,
> 
>I have one folder named "scripts_JMbayes", wich contains 10 R scripts.
>I can read them properly by doing:
> 
>> pathnames <- list.files(pattern="[.]R", path="Mydir/scripts_JMbayes",
>>full.names = TRUE)
>> sapply(pathnames, USE.NAMES = FALSE, FUN = source,)
> 
>However, R generates the following message:
> 
>        [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9]  [,10]
>value   ?     ?     ?     ?     ?     ?     ?     ?     ?     ?
>visible FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> 
>What does it mean and what should I change to avoid this message?
>Any help would be appreciated!
> 
>Best,
> 
>Frank
>
>                                         
>       [[alternative HTML version deleted]]
>
>______________________________________________
>R-help@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.

______________________________________________
R-help@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.

Reply via email to