On Thu, 13 Sep 2018, Duncan Murdoch wrote:> What did you try? Prefixing with either ./ or / doesn't make any sense.Duncan, Using linux (and perhaps other unices) ./ and / refer to the current directory. My code, to print to the sub-directory (../analyses/stat-summaries/) when the script is being run in ../analyses: sink('stat-summaries/estacada-wnw-precip.txt') print(/summary(estacada_wnw_wx)) sink() Rich
On 09/14/2018 10:49 AM, Rich Shepard wrote:> On Thu, 13 Sep 2018, Duncan Murdoch wrote: > >> What did you try?? Prefixing with either ./ or / doesn't make any sense. > > Duncan, > > ? Using linux (and perhaps other unices) ./ and / refer to the current > directory.This is simply incorrect; "./" refers to the current directory but "/" refers to the root directory. Note that sink("./mung.txt") gives the same result as sink("mung.txt"). I.e. the "./" is redundant. If you have a directory "gorp" in your current directory, then sink("gorp/mung.txt") will put the sink() output into the file "mung.txt" in the directory "gorp". <SNIP> cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276
On Fri, 14 Sep 2018, Rolf Turner wrote:> This is simply incorrect; "./" refers to the current directory but "/" refers > to the root directory.Rolf, I was not sufficientl clear.> Note that sink("./mung.txt") gives the same result as sink("mung.txt"). I.e. > the "./" is redundant. > > If you have a directory "gorp" in your current directory, then > > sink("gorp/mung.txt") > > will put the sink() output into the file "mung.txt" in the directory "gorp".sink('stat-summaries/estacada-wnw-precip.txt') print(summary(estacada_se_wx)) sink() results in 24: sink('stat-summaries/estacada-wnw-precip.txt') 25: print(/ ^ Does not matter if I use single or double quotes. Regards, Rich
In my experience, any path that can be used at the shell prompt in a unix-alike can be used anywhere that R wants a file name. [that is, when running R on a unix-alike system, and when pwd at the shell prompt returns the same value as getwd() in R] Hopefully, that helps... -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell 925-724-7509 ?On 9/13/18, 3:49 PM, "R-help on behalf of Rich Shepard" <r-help-bounces at r-project.org on behalf of rshepard at appl-ecosys.com> wrote: On Thu, 13 Sep 2018, Duncan Murdoch wrote: > What did you try? Prefixing with either ./ or / doesn't make any sense. Duncan, Using linux (and perhaps other unices) ./ and / refer to the current directory. My code, to print to the sub-directory (../analyses/stat-summaries/) when the script is being run in ../analyses: sink('stat-summaries/estacada-wnw-precip.txt') print(/summary(estacada_wnw_wx)) sink() 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.
On Thu, 13 Sep 2018, MacQueen, Don wrote:> In my experience, any path that can be used at the shell prompt in a > unix-alike can be used anywhere that R wants a file name.Don, That's been my experiences, too.> Hopefully, that helps...That's why I don't understand why the plot() function accepts the different directory while the sink() function (here) doesn't. I showed R rejecting: sink('stat-summaries/estacada-se-precip.txt') print(summary(estacada_se_wx)) sink() while accepting: pdf('../images/rainfall-estacada-se.pdf') <snip xyplot() function> plot(rain_est_se) dev.off() Changing the sink() file to './stat-summaries/estacada-se-precip.txt' generates the same error while I regularly use this syntax to copy files or specify the relative path to an executable file. Regards, Rich
? Thu, 13 Sep 2018 15:49:52 -0700 (PDT) Rich Shepard <rshepard at appl-ecosys.com> ?????:> sink('stat-summaries/estacada-wnw-precip.txt') > print(/summary(estacada_wnw_wx)) > sink()Just remove the slash from your print command (line 25 of rainfall-dubois-crk-all.r) because it's a syntax error (must be a typo). I.e. the above should be print(summary(estacada_wnw_wx)), not print(/summary(estacada_wnw_wx)) (do you notice the difference?). The rest of your sequence of commands is fine. -- Best regards, Ivan
On Fri, 14 Sep 2018, Ivan Krylov wrote:> Just remove the slash from your print command (line 25 of > rainfall-dubois-crk-all.r) because it's a syntax error (must be a typo). > I.e. the above should be print(summary(estacada_wnw_wx)), not > print(/summary(estacada_wnw_wx)) (do you notice the difference?). The rest > of your sequence of commands is fine.Ivan, Yes, it was and I did not see it each time I looked at the code, ignoring the error message point me to it. I've now installed lintr and will use that on all my scripts before I run them. Regards, Rich