Re: [R] sink() output to another directory

2018-09-14 Thread Rich Shepard
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

Re: [R] sink() output to another directory

2018-09-14 Thread Ivan Krylov
В Thu, 13 Sep 2018 15:49:52 -0700 (PDT) Rich Shepard пишет: > 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

Re: [R] sink() output to another directory [RESOLVED]

2018-09-14 Thread Rich Shepard
On Thu, 13 Sep 2018, Rich Shepard wrote: sink('stat-summary/example-output.txt') print(summary(df)) sink() My apologies to everyone for not seeing a typo further in the script. I had the path to the appropriate directory in the sink() function and the print() function had only the

Re: [R] sink() output to another directory

2018-09-14 Thread Sorkin, John
of Rich Shepard Sent: Friday, September 14, 2018 8:38 AM To: R-help Subject: Re: [R] sink() output to another directory CAUTION: This message originated from a non UMB, UMSOM, FPI, or UMMS email system. Whether the sender is known or not known, hover over any links before clicking and use caution ope

Re: [R] sink() output to another directory

2018-09-14 Thread Rich Shepard
On Thu, 13 Sep 2018, Bert Gunter wrote: I find your "explanation" confusing. You appear to be misusing print(). Please read ?print carefully. You print objects in R, not files. Objects in R do not have "/" in their names (without some trickery). See ?make.names . Bert, I had read both

Re: [R] sink() output to another directory

2018-09-13 Thread Peter Langfelder
Apologies if my advice wasn't clear: the file you want to write to goes in the sink() function/command. You can put the file anywhere on your file system, no need to write into current directory and then move the file. The print command is completely unaware of the file you point to in sink().

Re: [R] sink() output to another directory

2018-09-13 Thread Henrik Bengtsson
On Thu, Sep 13, 2018 at 7:12 PM Rich Shepard wrote: > > On Thu, 13 Sep 2018, Henrik Bengtsson wrote: > > >> sink('stat-summaries/estacada-se-precip.txt') > >> print(summary(estacada_se_wx)) > >> sink() > >> > >> while accepting: > >> > >> pdf('../images/rainfall-estacada-se.pdf') > >> > >>

Re: [R] sink() output to another directory

2018-09-13 Thread Jeff Newmiller
It is not possible for the current working directory to begin with "../". That is like saying n=n-1, because once follow the two dots up to the next directory the two dots refer to the next directory up. I don't think anyone in this list understands what is going on for you, so I recommend

Re: [R] sink() output to another directory

2018-09-13 Thread Rolf Turner
On 09/14/2018 02:12 PM, Rich Shepard wrote: On Thu, 13 Sep 2018, Henrik Bengtsson wrote: sink('stat-summaries/estacada-se-precip.txt') print(summary(estacada_se_wx)) sink() while accepting: pdf('../images/rainfall-estacada-se.pdf')   plot(rain_est_se) dev.off()    Changing the sink() file

Re: [R] sink() output to another directory

2018-09-13 Thread Bert Gunter
I find your "explanation" confusing. You appear to be misusing print(). Please read ?print carefully. You print objects in R, not files. Objects in R do not have "/" in their names (without some trickery). See ?make.names . -- Bert Bert Gunter "The trouble with having an open mind is that

Re: [R] sink() output to another directory

2018-09-13 Thread Peter Langfelder
There is no path in print. The path (file) is set in sink(). Peter On Thu, Sep 13, 2018 at 4:35 PM Rich Shepard wrote: > On Thu, 13 Sep 2018, Peter Langfelder wrote: > > > Remove the / from the print command, it does not belong there. > > Peter, > >So the print() function cannot accept a

Re: [R] sink() output to another directory

2018-09-13 Thread Peter Langfelder
For the second time: Rich, there should be no slash in the print() command. Use the form sink("../directory/file") print(summary(foo)) ### no slashes here sink(NULL) Peter On Thu, Sep 13, 2018 at 7:12 PM Rich Shepard wrote: > On Thu, 13 Sep 2018, Henrik Bengtsson wrote: > > >>

Re: [R] sink() output to another directory

2018-09-13 Thread Rich Shepard
On Thu, 13 Sep 2018, Henrik Bengtsson wrote: sink('stat-summaries/estacada-se-precip.txt') print(summary(estacada_se_wx)) sink() while accepting: pdf('../images/rainfall-estacada-se.pdf') plot(rain_est_se) dev.off() Changing the sink() file to './stat-summaries/estacada-se-precip.txt'

Re: [R] sink() output to another directory

2018-09-13 Thread Henrik Bengtsson
On Thu, Sep 13, 2018 at 6:05 PM Rich Shepard wrote: > > 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. > > >

Re: [R] sink() output to another directory

2018-09-13 Thread Rich Shepard
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()

Re: [R] sink() output to another directory

2018-09-13 Thread MacQueen, Don via R-help
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

Re: [R] sink() output to another directory

2018-09-13 Thread Rich Shepard
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

Re: [R] sink() output to another directory

2018-09-13 Thread Rich Shepard
On Thu, 13 Sep 2018, Peter Langfelder wrote: Remove the / from the print command, it does not belong there. Peter, So the print() function cannot accept a relative path to a different directory for its output? This does seem to be the case: source('rainfall-dubois-crk-all.r') Error in

Re: [R] sink() output to another directory

2018-09-13 Thread Rolf Turner
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; "./"

Re: [R] sink() output to another directory

2018-09-13 Thread Peter Langfelder
Remove the / from the print command, it does not belong there. sink("../directory/file.txt"); print(summary(foo)) sink(NULL) On Thu, Sep 13, 2018 at 4:03 PM Rich Shepard wrote: > On Thu, 13 Sep 2018, Rich Shepard wrote: > > > sink('example-output.txt') > > print(summary(df)) > > sink() > >

Re: [R] sink() output to another directory

2018-09-13 Thread Rich Shepard
On Thu, 13 Sep 2018, Rich Shepard wrote: sink('example-output.txt') print(summary(df)) sink() Let me expand on this. When the script contains # Open PDF device to save plot pdf('../images/rainfall-estacada-se.pdf') ... plot(rain_est_se) dev.off() the file, rainfall-estacada-se.pdf is

Re: [R] sink() output to another directory

2018-09-13 Thread Rich Shepard
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

Re: [R] sink() output to another directory

2018-09-13 Thread Henrik Bengtsson
On Thu, Sep 13, 2018 at 3:33 PM Rich Shepard wrote: > >Neither ?sink nor ?capture.output indicates how the output file can be > specified to be in a directory other than the cwd. > >When the cwd is ../analyses/ and I want the output to be in > ../analyses/stat-summaries/ how do I write

[R] sink() output to another directory

2018-09-13 Thread Rich Shepard
Neither ?sink nor ?capture.output indicates how the output file can be specified to be in a directory other than the cwd. When the cwd is ../analyses/ and I want the output to be in ../analyses/stat-summaries/ how do I write this? sink('example-output.txt') print(summary(df)) sink()