[R] Error: level sets of factors are different?

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri Aug 17 17:48:02 CEST 2012


The length of a vector of yes/no answers has little to do with the number of possible responses (2). Factors keep both pieces of information.

If you only have yes responses in your data set, when converted to factor you would have to tell R that other responses  were possible.

I prefer to avoid working with factors until I need them.  Use the str function to investigate where factors are being introduced and either use options to keep the data as character or convert it back to character if you can't figure that out.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Sri krishna Devarayalu Balanagu <balanagudevarayulu at gvkbio.com> wrote:

>Why the error is coming? even though the length of outcome.new$compkey
>and outcome.new$armkey were exactly same.
>Can anyone help?
>
>setwd("D:/AZ")
>library("RODBC")
>cdb_cnct <-
>odbcConnectExcel("AZIF_DC_GVK_NSCLC_MSALL_287papers_02072012_141450_v1_4.xls")
>outcomes <- sqlFetch(cdb_cnct, "Outcomes_info")
>odbcClose(cdb_cnct)
>rm(cdb_cnct)
>sink("Dependency checks.log")
>outcomes[(outcomes$Comparator != 9999), ] -> outcome
>compkey <- paste(outcome$Comparator, outcome$Comparator_Subarm,
>sep='_')
>armkey <- paste(outcome$Arm_ID, outcome$SubArm_ID, sep='_')
>outcome.new <- cbind(outcome, compkey, armkey)
>invalid.ids <- outcome.new[outcome.new$compkey == outcome.new$armkey,
>c("Assessment_record_ID")]
>
>Error in Ops.factor(outcome.new$compkey, outcome.new$armkey) :
>  level sets of factors are different
>
>
>________________________________
>Notice: The information contained in this electronic mail message is
>intended only for the use of the designated recipient. This message is
>privileged and confidential. and the property of GVK BIO or its
>affiliates and subsidiaries. If the reader of this message is not the
>intended recipient or an agent responsible for delivering it to the
>intended recipient, you are hereby notified that you have received this
>message in error and that any review, dissemination, distribution, or
>copying of this message is strictly prohibited. If you have received
>this communication in error, please notify us immediately by telephone
>+91-40-66929999<tel:%2B91-40-66929999> and destroy any and all copies
>of this message in your possession (whether hard copies or
>electronically stored copies).
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>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