hb@maths.lth.se
2003-Sep-03 09:08 UTC
[Rd] Last line in .Rprofile must have newline (PR#4056)
Full_Name: Henrik Bengtsson Version: R v1.7.1 OS: WinXP Pro, Solaris 9 Submission from: (NULL) (130.235.2.229) A colleague of mine who is new to R had problems setting up his .Rprofile and we tracked it down to the following. On both WinXP and Solaris with Rv1.7.1 we noticed that the *last* line in .Rprofile has to have a *newline* to be evaluated. For instance, starting R with the following .Rprofile: a <- 1 <newline> b <- 2 will only set the variable 'a'. Adding a newline to the second line will set 'b' too. FYI: I browsed through ?.Rprofile and R-intro.html to see if it was document, but it does not seem so. I also checked with the behavior of source() too, but there a newline is not required. Best wishes Henrik Bengtsson Lund University> str(R.Version())List of 11 $ platform: chr "sparc-sun-solaris2.9" $ arch : chr "sparc" $ os : chr "solaris2.9" $ system : chr "sparc, solaris2.9" $ status : chr "" $ major : chr "1" $ minor : chr "7.1" $ year : chr "2003" $ month : chr "06" $ day : chr "16" $ language: chr "R"> str(R.Version())List of 11 $ platform: chr "i386-pc-mingw32" $ arch : chr "i386" $ os : chr "mingw32" $ system : chr "i386, mingw32" $ status : chr "" $ major : chr "1" $ minor : chr "7.1" $ year : chr "2003" $ month : chr "06" $ day : chr "16" $ language: chr "R"
Prof Brian Ripley
2003-Sep-03 09:25 UTC
[Rd] Last line in .Rprofile must have newline (PR#4056)
Why do you think this a bug in R? All source files should end in the EOL character: R command lines are incomplete without it (or a semicolon) and this is covered by the standard rules. (It also happens at the command line, BTW.) That we have worked around the user error in a number of places does not make it a bug elsewhere. Files such as .Rprofile are handled at a much lower level than source(), and the convenience of the connections mechanism (which allows non-native line endings for example, as well as incomplete last lines) is not available. For your reference, it is the behaviour of R_ReplFile in src/main/main.c on PARSE_EOF that matters. On Wed, 3 Sep 2003 hb@maths.lth.se wrote:> Full_Name: Henrik Bengtsson > Version: R v1.7.1 > OS: WinXP Pro, Solaris 9 > Submission from: (NULL) (130.235.2.229) > > > A colleague of mine who is new to R had problems setting up his .Rprofile and we > tracked it down to the following. On both WinXP and Solaris with Rv1.7.1 we > noticed that the *last* line in .Rprofile has to have a *newline* to be > evaluated. For instance, starting R with the following .Rprofile: > > a <- 1 <newline> > b <- 2 > > will only set the variable 'a'. Adding a newline to the second line will set 'b' > too. FYI: I browsed through ?.Rprofile and R-intro.html to see if it was > document, but it does not seem so. I also checked with the behavior of source() > too, but there a newline is not required. > > Best wishes > > Henrik Bengtsson > Lund University > > > str(R.Version()) > List of 11 > $ platform: chr "sparc-sun-solaris2.9" > $ arch : chr "sparc" > $ os : chr "solaris2.9" > $ system : chr "sparc, solaris2.9" > $ status : chr "" > $ major : chr "1" > $ minor : chr "7.1" > $ year : chr "2003" > $ month : chr "06" > $ day : chr "16" > $ language: chr "R" > > > str(R.Version()) > List of 11 > $ platform: chr "i386-pc-mingw32" > $ arch : chr "i386" > $ os : chr "mingw32" > $ system : chr "i386, mingw32" > $ status : chr "" > $ major : chr "1" > $ minor : chr "7.1" > $ year : chr "2003" > $ month : chr "06" > $ day : chr "16" > $ language: chr "R" > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > >-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595