Can anyone explain this behavior? Essentially, I've created a short file to be read in via source() that gets some descriptive information on a series of variables in a data frame. For each variable, I do three things: print('last.hc.actors') quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T) stem(last.hc.actors) where the variable name is (in this case) last.hc.actors. All that is fine, except that R seems to quietly ignore all the quantile() steps. I narrowed it down to bare minimum, trying with a file, test.R, that contains simply: quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T) and here's the result:> source('test.R') >on the other hand, if I make test.R be simply: stem(last.hc.actors) here's the result:> source('test.R')The decimal point is 1 digit(s) to the right of the | 0 | 00000000000000000000000000000000000000000000000000000000000000000000+451 1 | 00000000000000000000000000000000000000000111111111111111111111111111+298 2 | 00000000000000000000000000000000011111111111111111111111111111111222+227 3 | 00000000000000000000000000001111111111111111111111111111222222222222+175 4 | 00000000000000000000001111111111111111111111222222222222222222222233+139 5 | 00000000000000000000111111111111111111122222222222222222223333333333+109 6 | 00000000000000000011111111111111111122222222222222222233333333333333+100 7 | 00000000000000000011111111111111111122222222222222222233333333333333+100 8 | 00000000000000001111111111111111222222222222222233333333333333344444+61 9 | 00000000000001111111111111222222222223333333333444444444555555556666+14 10 | 00000001111111222222233333334444444555555666666777777888888999999 11 | 00000111112222233333444445555566667777888999 12 | 000111222333444555666777888999 13 | 0011223456789 14 | 0123456789 15 | 0123456789 16 | 0123456789 17 | 0123456789 18 | 01>(sorry for the poor line wrapping) Finally, the quantile() command works fine directly pasted onto the command line:> quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T)0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% 0 4 10 16 24 34 45 59 74 91 181>any ideas? Thanks. ---------------------------------------------------------------------- Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin aperrin at socrates.berkeley.edu - aperrin at igc.apc.org -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Even more strangeness - it works fine in batch mode: R BATCH ../last.stemleaf.R last.stemleaf.out gets the quantile() output just fine. ---------------------------------------------------------------------- Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin aperrin at socrates.berkeley.edu - aperrin at igc.apc.org On Sun, 25 Feb 2001, Andrew Perrin wrote:> > Can anyone explain this behavior? Essentially, I've created a short file > to be read in via source() that gets some descriptive information on a > series of variables in a data frame. For each variable, I do three > things: > > print('last.hc.actors') > quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T) > stem(last.hc.actors) > > where the variable name is (in this case) last.hc.actors. All that is > fine, except that R seems to quietly ignore all the quantile() steps. I > narrowed it down to bare minimum, trying with a file, test.R, that > contains simply: > > quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T) > > and here's the result: > > source('test.R') > > > > on the other hand, if I make test.R be simply: > > stem(last.hc.actors) > > here's the result: > > source('test.R') > > The decimal point is 1 digit(s) to the right of the | > > 0 | > 00000000000000000000000000000000000000000000000000000000000000000000+451 > 1 | > 00000000000000000000000000000000000000000111111111111111111111111111+298 > 2 | > 00000000000000000000000000000000011111111111111111111111111111111222+227 > 3 | > 00000000000000000000000000001111111111111111111111111111222222222222+175 > 4 | > 00000000000000000000001111111111111111111111222222222222222222222233+139 > 5 | > 00000000000000000000111111111111111111122222222222222222223333333333+109 > 6 | > 00000000000000000011111111111111111122222222222222222233333333333333+100 > 7 | > 00000000000000000011111111111111111122222222222222222233333333333333+100 > 8 | > 00000000000000001111111111111111222222222222222233333333333333344444+61 > 9 | > 00000000000001111111111111222222222223333333333444444444555555556666+14 > 10 | 00000001111111222222233333334444444555555666666777777888888999999 > 11 | 00000111112222233333444445555566667777888999 > 12 | 000111222333444555666777888999 > 13 | 0011223456789 > 14 | 0123456789 > 15 | 0123456789 > 16 | 0123456789 > 17 | 0123456789 > 18 | 01 > > > > (sorry for the poor line wrapping) > > Finally, the quantile() command works fine directly pasted onto the > command line: > > > quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T) > 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% > 0 4 10 16 24 34 45 59 74 91 181 > > > > any ideas? Thanks. > > ---------------------------------------------------------------------- > Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology > Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin > aperrin at socrates.berkeley.edu - aperrin at igc.apc.org > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sun, 25 Feb 2001, Andrew Perrin wrote:> > Can anyone explain this behavior? Essentially, I've created a short file > to be read in via source() that gets some descriptive information on a > series of variables in a data frame. For each variable, I do three > things: > > print('last.hc.actors') > quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T) > stem(last.hc.actors) > > where the variable name is (in this case) last.hc.actors. All that is > fine, except that R seems to quietly ignore all the quantile() steps.R is not ignoring quantile(), it simply isn't printing the results, because you haven't asked it to. Most R functions do not print their results: that's what print() is for. They return their results so they can either be printed or used for further calculations. This isn't always obvious to a new user, because if you invoke a function at the command line the result is print()ed, so> 1+1[1] 2 looks just like> print(1+1)[1] 2 When source()ing a file, or inside a function, this doesn't happen. You need to call print() or cat() explicitly to display things on the screen. In you example you happened to have two other functions, print() and stem(), that *do* explicitly display their results on the screen. You probably wanted print(quantile(last.hc.actors,probs=seq(0,1,0.1),na.rm=T) ) or alternatively, source(,echo=TRUE) -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._