[R] Baffled: triggering error message with an sd result in odfWeave?
Tubin
sredmonson at yahoo.com
Mon Dec 15 17:55:32 CET 2008
Sarah Goslee says: "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."
OK, here's summary and str for those three variables:
> summary(trainscores)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1314 66.8400 83.3000 78.4900 98.0700 99.9000
> str(trainscores)
num [1:257] 87.0 99.9 47.2 99.7 67.2 ...
> summary(trainlength)
Min. 1st Qu. Median Mean 3rd Qu. Max.
257 257 257 257 257 257
> str(trainlength)
int 257
> summary(traindev)
Min. 1st Qu. Median Mean 3rd Qu. Max.
22.31 22.31 22.31 22.31 22.31 22.31
> str(traindev)
num 22.3
This is run on my entire dataset. The program I've written actually takes
the overall dataset and divides it into several subgroups, then runs the
analysis and calls odfWeave for each. Hence the checks to ensure that the
dataset is not empty before running it.
So the code to calculate traindev works fine in the R window. I can perform
further calculations on it, etc. Additionally,
trainmean<-if (trainlength >0) round(mean(trainscores, na.rm=T),1) else ""
on the same data produces a result that imports fine into odfWeave. And
as noted below, a similarly-constructed sd calculation on a different subset
of the data is giving me no problems elsewhere in the document.
Thanks for looking at this with me!
* * * * *
to summarize the previous message,
in the codeblock
trainusers<-sessionusers[sessionusers$tally=="train",] #training
sessions only
trainscores<-if (reporttype=="Competency")
trainusers$competence_score_total*100 else
trainusers$knowledge_score_total*100
trainlength<- length(trainusers[,1])
trainmean<-if (trainlength >0)
round(mean(trainscores, na.rm=T),1) else ""
traindev <- if (trainlength>0) sd(trainscores,
na.rm=T) else ""
the variable traindev is causing this error when I try to report it using
odfWeave:
Error: 1: Start tag expected, '<' not found
But the variables trainlength and trainmean import into the document without
problems.
Meanwhile the similarly-constructed
postusers<-sessionusers[sessionusers$tally=="post",] #post sessions
only
postscores<-if (reporttype=="Competency")
postusers$competence_score_total*100 else
postusers$knowledge_score_total*100
postlength<- length(postusers[,1])
postmean<- if (postlength>0)
round(mean(postscores, na.rm=T),1) else ""
postsd<- if (postlength>0) round(sd(postscores,
na.rm=T),1) else ""
causes no problems with any variables including the sd variable.
--
View this message in context: http://www.nabble.com/Baffled%3A-triggering-error-message-with-an-sd-result-in-odfWeave--tp21016679p21017460.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list