Re: [R] problem with an IF statement?

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 29 Jul 2005 - 02:45:39 EST

Thomas Lumley <tlumley@u.washington.edu> writes:

> On Thu, 28 Jul 2005, tom wright wrote:
>
> > Can somebody please take a look at this and tell me whats going wrong?
> > It seems to be parsing wronly around the 'if' statement and gives me a
> > directory listing.
>
> I think the code that you posted is not quite the code you were
> using.
>
> The problem is that your code had tab characters in it. The readline
> support in R interprets a tab character as a request to complete a file
> name. If it can't do that unambiguously it will show the directory
> listing in response to a second tab.
>
> Your email program has turned the tabs into spaces, which fixes the
> problem. Your text editor probably has a way to do this.

I did see the TABs and they're still present for me in the cited code below, so I suppose it is Thomas' system which occasionally converts them to spaces...  

> Incidentally, this happens only on certain platforms, which is why the
> posting guide suggests you should say what system you are using.
>
> -thomas
>
>
> > Thanks in advance
> > Tom
> > N.B. datan is an invented dataset
> >
> >
> > xvals<-c(1,0.4,0.2)
> > datan<-data.frame(s1=c(3,4,5),s2=c(5,5,5),s3=c(21,55,34),s4=c(5,3,2))
> >
> > datan$sint<-NA
> > datan$sgrad<-NA
> > for(icount in 1:dim(datan)[1]) {
> > yvals<-c(datan[icount,4],datan[icount,3],datan[icount,2])
> > if((is.na(yvals[1]) + is.na(yvals[2]) + is.na(yvals[3]))<2) {
> > g<-lm(yvals~xvals)
> > datan$sint[icount]<-g$coef[1]
> > datan$sgrad[icount]<-g$coef[2]
> > }
> > }
> >
> > ______________________________________________
> > 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
> >
>
> Thomas Lumley Assoc. Professor, Biostatistics
> tlumley@u.washington.edu University of Washington, Seattle
>
> ______________________________________________
> 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
>

-- 
   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.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
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
Received on Fri Jul 29 03:01:28 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:07 EST