Navarre Sabine wrote:
Make all factor objects to include *all* levels, I guess (since the huge
exmple stuff below is not reproducible).
Uwe Ligges
> Hi,
> I would like to compare 2 lists resulted from a sql query! bu there are
> different levels, so when I want to do:
>
>
> release1<-sqlQuery(channel,paste("select distinct c.ID,c.Title TitleCrit from
> category cat, category_criteria cc, criteria c, question_criteria qc,
> question q, form_question fq, form f, release_form rf, release r,
> product_release pr, product p where cat.ID=cc.category and cc.criteria=c.ID
> and c.ID=qc.criteria and qc.question=q.ID and fq.question=q.ID and
> fq.form=f.ID and f.ID=rf.form and rf.release=r.ID and r.ID=pr.release and
> pr.product=p.ID and r.ID='",param1,"';",sep=""))
>
> release2<-sqlQuery(channel,paste("select distinct c.ID,c.Title TitleCrit from
> category cat, category_criteria cc, criteria c, question_criteria qc,
> question q, form_question fq, form f, release_form rf, release r,
> product_release pr, product p where cat.ID=cc.category and cc.criteria=c.ID
> and c.ID=qc.criteria and qc.question=q.ID and fq.question=q.ID and
> fq.form=f.ID and f.ID=rf.form and rf.release=r.ID and r.ID=pr.release and
> pr.product=p.ID and r.ID='",param2,"';",sep=""))
>
> data_NA<-matrix(data=0,nrow=length(release$Title),ncol=length(formv$TitleCrit),byrow=TRUE,
>
> dimnames=list(as.factor(release$Title),paste(as.factor(formv$TitleCrit),"(",formv$first_letter,")",sep="")))
>
> for (i in 1:length(formv$TitleCrit))
> {
> for(k in 1: length(release1$TitleCrit))
> {
> if(formv$TitleCrit[i]==release1$TitleCrit[k])
> {
> data_NA[1,formv$TitleCrit[[i]]]<-1
> }
> else{data_NA[1,formv$TitleCrit[[i]]]<-NA}
> }
> }
>
> for (i in 1:length(formv$TitleCrit))
> {
> for(k in 1: length(release2$TitleCrit))
> {
> if(formv$TitleCrit[i]==release2$TitleCrit[k])
> {
> data_NA[2,formv$TitleCrit[[i]]]<-1
> }
> else{data_NA[2,formv$TitleCrit[[i]]]<-NA}
> }
> }
>
>
>
> On R: Error in Ops.factor(formv$TitleCrit[i], release2$TitleCrit[k]) : level
> sets of factors are different
>
> How can I compare these 2 lists?
>
> Thanks
>
>
>
> SABINE
>
>
>
>
>
> ---------------------------------
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html