[R] line breaks

Thomas Lumley tlumley at u.washington.edu
Mon Mar 18 17:31:10 CET 2002


On 18 Mar 2002, Michaell Taylor wrote:

>
>
> I have a question about the function of line feeds/carriage returns in
> an all linux (R, vi to write scripts) environment.  In my scripts I have
> a few functions, using { or ( to wrap commands on the next line.
> Usually this is fine, but sometimes R appears confused by line wrappings
> (more likely of course it is me who is confused).  I tried ';' to
> explictly break the line, but no dice.
>
> An example (partial function).
>
>
> inrange _ function(v,Y,s,z,mlv,met){
> 	lower _ mean(v[data$yr==Y])-(var(v[data$yr==Y])^.5)
> 	upper _ mean(v[data$yr==Y])+(var(v[data$yr==Y])^.5)
> 	ML _ mlv[ML$yr==Y & ML$metcode==met]
> 	diff _ 0
> 	if (ML<lower) {diff <- lower-ML;   # tried with and without ;
> 		v <<- v-diff}
> 	}
>
> gives:
>
> > inrange _ function(v,Y,s,z,mlv,met){
> + lower _ mean(v[data$yr==Y])-(var(v[data$yr==Y])^.5)
> + upper _ mean(v[data$yr==Y])+(var(v[data$yr==Y])^.5)
> + ML _ mlv[ML$yr==Y & ML$metcode==met]
> + diff _ 0
> + if (ML<lower) {diff <- lower-ML; v <<- v-diff}}
> > inrange _ function(v,Y,s,z,mlv,met){
> + lower _ mean(v[data$yr==Y])-(var(v[data$yr==Y])^.5)
> + upper _ mean(v[data$yr==Y])+(var(v[data$yr==Y])^.5)
> + ML _ mlv[ML$yr==Y & ML$metcode==met]
> + diff _ 0
> + if (ML<lower) {diff <- lower-ML;
> +
> Display all 100 possibilities? (y or n)
> ActualTen.dta         .check.R.swl          .marketFix.log.swp
> .
> .
> contents of directory

It's not Bill Gates' fault.  It's the readline library -- it's trying to
do TAB completion of file names.

Don't use TAB characters in interactive R sessions if you're running
readline.

	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list