On 4 Μαϊ 2005, at 11:41 πμ, Uwe Ligges wrote:

Hai Lin wrote:

Hello R users, I have R script files writen in my pc laptop. I encountered problems when I run those files in R in Mac OS X (10.3.5). Are there any ways in R that can make .R files executable?


It should work, at once, given you have not used Windows specific commands, hard coded paths etc...

Uwe Ligges



Hai,

On the mac, try to open the files in a "unixy" editor, such as emacs, pico, vi. If your file looks something like this (look for ^M):

first line of R commands^Msecond line of R commands^Metc

then the problem is line endings (that are different between platforms).

To fix this, you can open the file(s) in an editor, e.g. SubEthaEdit (free for personal and educational use) and then change the line endings (Format->Line endings->Convert to unix line endings..)

Another approach (useful if you want to batch-convert a lot of files) is to run a script like this:

 #!/bin/sh
    tr '\r' '\n' < $1 >MKTMP001
    mv -f MKTMP001 $1

You can save this as a file, e.g. call it stripCtrlM, make it executable (chmod +x stripCtrlM) and run it:

stripCtrlM filesWithCtrlM.R

or stripCtrlM *.R to convert all .R files in a directory

Hope this helps,

Costas






Thanks in advance
Kevin
__________________________________________________
[[alternative HTML version deleted]]
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html





--
Constantinos Antoniou, Ph.D.
Massachusetts Institute of Technology
Intelligent Transportation Systems Program
77 Massachusetts Ave., Rm. 1-249, Cambridge, MA 02139

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to