[Rd] (PR#14012)

2009-10-17 Thread sje30
I think Rscript has a problem running files that have mac encodings
for newline (^M rather than ^J on linux).  If I source the file within
R, it works okay:

 source('j.R')
[1] MEA_data/sernagor_new/CRX_P7_1.txt

But if I run the file using Rscript on a linux box I get a strange
error message: 

$ Rscript --vanilla j.R

Execution halted

The example script j.R is at http://www.damtp.cam.ac.uk/user/sje30/j.R
rather than attaching it here.  I don't think there is anything
specific about the script though apart from the line endings.

Stephen

--please do not edit the information below--

Version:
 platform = x86_64-pc-linux-gnu
 arch = x86_64
 os = linux-gnu
 system = x86_64, linux-gnu
 status = 
 major = 2
 minor = 9.2
 year = 2009
 month = 08
 day = 24
 svn rev = 49384
 language = R
 version.string = R version 2.9.2 (2009-08-24)

Locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C

Search Path:
 .GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, 
package:datasets, package:methods, Autoloads, package:base

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] (PR#14012)

2009-10-17 Thread Seth Falcon
* On 2009-10-16 at 15:00 +0200 sj...@damtp.cam.ac.uk wrote:
 I think Rscript has a problem running files that have mac encodings
 for newline (^M rather than ^J on linux).  If I source the file within
 R, it works okay:

  source('j.R')
 [1] MEA_data/sernagor_new/CRX_P7_1.txt
 
 But if I run the file using Rscript on a linux box I get a strange
 error message: 
 
 $ Rscript --vanilla j.R
 
 Execution halted

I think you are right that Rscript is unhappy to handle files with CR
line terminators.  But IIUC, the purpose of Rscript is to enable R
script execution on unix-like systems like:

   #!/path/to/Rscript --vanilla
   print(1:10)

So then I'm not sure how useful it is for Rscript to handle such
files.  Why not convert to a more common and portable line termination
for your R script files?


+ seth

-- 
Seth Falcon | @sfalcon | http://userprimary.net/user

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] (PR#14012)

2009-10-17 Thread Gabor Grothendieck
Even though its not hard to convert files, I think it would be better
if R could directly handle different line endings since R tends to be
used in a cross platform way and its common to have files of different
line endings that originated from different systems.

On Sat, Oct 17, 2009 at 5:03 PM, Seth Falcon s...@userprimary.net wrote:
 * On 2009-10-16 at 15:00 +0200 sj...@damtp.cam.ac.uk wrote:
 I think Rscript has a problem running files that have mac encodings
 for newline (^M rather than ^J on linux).  If I source the file within
 R, it works okay:

  source('j.R')
 [1] MEA_data/sernagor_new/CRX_P7_1.txt

 But if I run the file using Rscript on a linux box I get a strange
 error message:

 $ Rscript --vanilla j.R
 
 Execution halted

 I think you are right that Rscript is unhappy to handle files with CR
 line terminators.  But IIUC, the purpose of Rscript is to enable R
 script execution on unix-like systems like:

   #!/path/to/Rscript --vanilla
   print(1:10)

 So then I'm not sure how useful it is for Rscript to handle such
 files.  Why not convert to a more common and portable line termination
 for your R script files?


 + seth

 --
 Seth Falcon | @sfalcon | http://userprimary.net/user

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] (PR#14012)

2009-10-17 Thread Peter Dalgaard

Seth Falcon wrote:

* On 2009-10-16 at 15:00 +0200 sj...@damtp.cam.ac.uk wrote:

I think Rscript has a problem running files that have mac encodings
for newline (^M rather than ^J on linux).  If I source the file within
R, it works okay:



source('j.R')

[1] MEA_data/sernagor_new/CRX_P7_1.txt

But if I run the file using Rscript on a linux box I get a strange
error message: 


$ Rscript --vanilla j.R

Execution halted


I think you are right that Rscript is unhappy to handle files with CR
line terminators.  But IIUC, the purpose of Rscript is to enable R
script execution on unix-like systems like:

   #!/path/to/Rscript --vanilla
   print(1:10)

So then I'm not sure how useful it is for Rscript to handle such
files.  Why not convert to a more common and portable line termination
for your R script files?


Notice also that other script interpreters aren't happy about CR line 
endings:


$ cat  x.sh
#!/bin/bash
echo hello

Now change the LF to CR and get

$ ./x.sh
bash: ./x.sh: /bin/bash^M: bad interpreter: No such file or directory

or (if you add a space)

$ ./x.sh
 echo hello: No such file or directory

$ bash -v ./x.sh
 echo hello

(overprinting is involved in the last one).

--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] (PR#14012)

2009-10-17 Thread Prof Brian Ripley

On Sat, 17 Oct 2009, Seth Falcon wrote:


* On 2009-10-16 at 15:00 +0200 sj...@damtp.cam.ac.uk wrote:

I think Rscript has a problem running files that have mac encodings
for newline (^M rather than ^J on linux).


I think those are Mac conventions for end-of-line, not for newline. 
Even in MacRoman encoding, Ctrl-M is carriage return and Ctrl-J is 
newline aka linefeed..



If I source the file within R, it works okay:



source('j.R')

[1] MEA_data/sernagor_new/CRX_P7_1.txt

But if I run the file using Rscript on a linux box I get a strange
error message:

$ Rscript --vanilla j.R

Execution halted


I think you are right that Rscript is unhappy to handle files with CR
line terminators.


More accurately, R's parser is: this applies to R CMD BATCH and R 
itself with redirection.  The point is that the documentation says
that R commands have to be separated by newline or semicolon and CR is 
neither.  (See, e.g. R-intro section 1.8.)


It is also documented that text-mode connections (which source() uses) 
map CR and CRLF to newline, so source() can accept CR-delimited files.


And the error message looks strange because it has CRs but not NLs in 
it (since the input did) and presumably the terminal used replaces not 
superposes characters.


What actually is claimed to be the bug here?  There is no subject 
line, and no clear statement.  Is that Rscript gives an error, that 
source() works or that the error message comes out mangled on a 
particular terminal?



But IIUC, the purpose of Rscript is to enable R script execution on 
unix-like systems like:


  #!/path/to/Rscript --vanilla
  print(1:10)

So then I'm not sure how useful it is for Rscript to handle such
files.  Why not convert to a more common and portable line termination
for your R script files?


+ seth

--
Seth Falcon | @sfalcon | http://userprimary.net/user

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



--
Brian D. Ripley,  rip...@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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel