Tubin
2008-Dec-15 16:12 UTC
[R] Baffled: triggering error message with an sd result in odfWeave?
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.
Sarah Goslee
2008-Dec-15 16:24 UTC
[R] Baffled: triggering error message with an sd result in odfWeave?
I'd take a good look at trainlength, trainscores and traindev using str() and summary(), and print at least part of each to the screen. If the same line of code works with one dataset and not another, the problem is more likely your data than your code. If that doesn't help you figure it out, posting the str() and summary() results here can help the R-helpers diagnose the problem. Sarah On Mon, Dec 15, 2008 at 11:12 AM, Tubin <sredmonson at yahoo.com> 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? >-- Sarah Goslee http://www.functionaldiversity.org
David Winsemius
2008-Dec-15 16:40 UTC
[R] Baffled: triggering error message with an sd result in odfWeave?
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.