[R] A logical comparison between two character strings in R

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Aug 21 16:54:29 CEST 2003


Lun Li <lun.li at glg.ed.ac.uk> writes:

> Thanks.
> 
> But, my question is:
> 
> > pro.name[1]
>        V1
> 1 B-29BT3
> > temp.name[1]
>     V1
> 1 A-1H
> > if(tem.name[1]==pro.name[1]){cat("ok")}
> 
> Error in Ops.factor(left, right) : Level sets of factors are different
> 
> How to compare them?

Then they are factors, not character variables. Use as.character on both
sides. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list