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') >> <snip xyplot() function> >> plot(rain_est_se) >> dev.off() >> >> Changing the sink() file to >> './stat-summaries/estacada-se-precip.txt' >> >> generates the same error > > "same error" as what? (ambiguity is the reason for not being able to > help you - all the replies in this thread this far are correct and on > the spot) > > BTW, not that it should matter, what is your operating system and version of R?Henrik, As I wrote in earlier messages: 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. The message that print() doesn't like the forward slash results when I specify 'stat-summaries/estacada-wnw-precip.txt' or './stat-summaries/estacada-wnw-precip.txt'. Running R-3.5.1 on Slackware-14.2. Rich
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 people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Sep 13, 2018 at 7:12 PM Rich Shepard <rshepard at appl-ecosys.com> 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') > >> <snip xyplot() function> > >> plot(rain_est_se) > >> dev.off() > >> > >> Changing the sink() file to > >> './stat-summaries/estacada-se-precip.txt' > >> > >> generates the same error > > > > "same error" as what? (ambiguity is the reason for not being able to > > help you - all the replies in this thread this far are correct and on > > the spot) > > > > BTW, not that it should matter, what is your operating system and version of R? > > Henrik, > > As I wrote in earlier messages: > > 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. > > The message that print() doesn't like the forward slash results when I > specify 'stat-summaries/estacada-wnw-precip.txt' or > './stat-summaries/estacada-wnw-precip.txt'. > > Running R-3.5.1 on Slackware-14.2. > > 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 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') >>> ? <snip xyplot() function> >>> plot(rain_est_se) >>> dev.off() >>> >>> ?? Changing the sink() file to >>> './stat-summaries/estacada-se-precip.txt' >>> >>> generates the same error >> >> "same error" as what? (ambiguity is the reason for not being able to >> help you - all the replies in this thread this far are correct and on >> the spot) >> >> BTW, not that it should matter, what is your operating system and >> version of R? > > Henrik, > > ? As I wrote in earlier messages: > > 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. > > ? The message that print() doesn't like the forward slash results when I > specify 'stat-summaries/estacada-wnw-precip.txt' or > './stat-summaries/estacada-wnw-precip.txt'. > > ? Running R-3.5.1 on Slackware-14.2.This would appear to have nothing to do with sink(). There is something weird about your data set estacada_se_wx or the summary thereof that print() doesn't like. If I do:> system("mkdir stat-summaries") > estacada_se_wx <- rnorm(10) > sink('stat-summaries/estacada-se-precip.txt') > print(summary(estacada_se_wx)) > sink() > system("cat stat-summaries/estacada-se-precip.txt")I get:> Min. 1st Qu. Median Mean 3rd Qu. Max. > -1.7292 -0.7621 0.5428 0.2808 1.2603 1.7702OMMMMMMM!!! cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276
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 <rshepard at appl-ecosys.com> 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') > >> <snip xyplot() function> > >> plot(rain_est_se) > >> dev.off() > >> > >> Changing the sink() file to > >> './stat-summaries/estacada-se-precip.txt' > >> > >> generates the same error > > > > "same error" as what? (ambiguity is the reason for not being able to > > help you - all the replies in this thread this far are correct and on > > the spot) > > > > BTW, not that it should matter, what is your operating system and > version of R? > > Henrik, > > As I wrote in earlier messages: > > 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. > > The message that print() doesn't like the forward slash results when I > specify 'stat-summaries/estacada-wnw-precip.txt' or > './stat-summaries/estacada-wnw-precip.txt'. > > Running R-3.5.1 on Slackware-14.2. > > 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. >[[alternative HTML version deleted]]
On Thu, Sep 13, 2018 at 7:12 PM Rich Shepard <rshepard at appl-ecosys.com> 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') > >> <snip xyplot() function> > >> plot(rain_est_se) > >> dev.off() > >> > >> Changing the sink() file to > >> './stat-summaries/estacada-se-precip.txt' > >> > >> generates the same error > > > > "same error" as what? (ambiguity is the reason for not being able to > > help you - all the replies in this thread this far are correct and on > > the spot) > > > > BTW, not that it should matter, what is your operating system and version of R? > > Henrik, > > As I wrote in earlier messages: > > 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. > > The message that print() doesn't like the forward slash results when I > specify 'stat-summaries/estacada-wnw-precip.txt' or > './stat-summaries/estacada-wnw-precip.txt'.Since it is impossible to get that error message (which is a syntax error, i.e. the R parser does not accept the code as written and it never gets to the point where the R engine even runs your code) for the code you are showing, I strongly suspect that you didn't source() the same file that you were editing (the one that contains the three-line code you are displaying above). I see from one of your later message that you've got it to work now. /Henrik> > Running R-3.5.1 on Slackware-14.2. > > 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, 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 ?print and ?print.default looking for information about placing the printed object in another directory, and found nothing. My initial assumption was that print() worked similar to plot(). I use plot() after specifying a pdf file as output and thought that sink() (which ?sink tells me diverts R output to a connection (and stops it as dev.off stops writing to the pdf file). That sink() apparently does not work the same way is why I posted my question. Regards, Rich