[R] Not able to filter factor, class

John Kane jrkrideau at inbox.com
Tue Aug 14 21:07:06 CEST 2012


Are you sure that you are not confusing the number of levels with the length of the vector?

John Kane
Kingston ON Canada


> -----Original Message-----
> From: balanagudevarayulu at gvkbio.com
> Sent: Tue, 14 Aug 2012 12:40:26 +0000
> To: r-help at r-project.org
> Subject: [R] Not able to filter factor, class
> 
> After importing data from Excel through ODBC.
> In the inclusion dataset, class(inclusion$Value) is coming as factor.
> After filtering the data, length(inclusion$Value == 0),the answer is
> coming as 4879, but actually Value contains only 225 rows. So how can I
> get the length as 225.
> Can anyone help?
> 
> setwd("D:/AZ")
> library("RODBC")
> cdb_cnct <-
> odbcConnectExcel("AZIF_DC_GVK_NSCLC_MSALL_287papers_02072012_141450_v1_4.xls")
> arm <- sqlFetch(cdb_cnct, "Arm")
> inclusion <- sqlFetch(cdb_cnct, "Inclusion")
> odbcClose(cdb_cnct)
> rm(cdb_cnct)
> names(inclusion)
> [1] "Trial_Design_ID"    "Reference_ID"       "Inclusion_Criteria"
> [4] "Value"              "F5"                 "F6"
>> class(inclusion$Value)
> [1] "factor"
> 
>> nrow(inclusion)
> [1] 4879
>> length(inclusion$Value == 0)
> [1] 4879
>> length(inclusion$Value == "0")
> [1] 4879
> ________________________________
> 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.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list