[R] Baffled: triggering error message with an sd result in odfWeave?

David Winsemius dwinsemius at comcast.net
Mon Dec 15 17:40:11 CET 2008


I think it because you are trying to use the if-else control  
construct, when you should be using the ifelse function:

?ifelse

Try (perhaps):
traindev <- ifelse( (trainlength>0), round(sd(trainscores, na.rm=T), 
1) , "")

You do seem to be mixing types, though, so perhaps you should use NA  
instead of "".

-- 
David Winsemius

On Dec 15, 2008, at 11:12 AM, Tubin wrote:

>
> I hope someone can point out my stupid error, because I'm baffled.
>
> I am calculating a bunch of variable values and then placing them in a
> document using odfWeave tags.
>
> This is working very nicely for every spot except one.
>
> One of the values I calculate is traindev:
>
> traindev <- if (trainlength>0) round(sd(trainscores, na.rm=T),1)  
> else ""
>
> when I try to insert this traindev value anywhere in my odfWeave  
> document
> (using \Sexpr{traindev} ), I get the following error:
> Start tag expected, '<' not found
> Error: 1: Start tag expected, '<' not found
>
> Another formula,
> postsd<- if (postlength>0)  round(sd(postscores, na.rm=T),1)  else ""
>
> does not trigger the same error.
>
> It's not something strange with the variable name; give any other  
> value to
> that variable and odfWeave works just fine.  It's not the spot on the
> document; any other tag works great in that spot and but traindev  
> triggers
> the error wherever I try to put it.
>
> I've spent a horrendously long time trying to figure it out. Can  
> anyone help
> me out?
>
> R version is 2.7.1
> odfWeave is whatever the latest version is
> os is Mac OS10.5.5
> -- 
> View this message in context: http://www.nabble.com/Baffled%3A-triggering-error-message-with-an-sd-result-in-odfWeave--tp21016679p21016679.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list