Error: Missign value where TRUE/FALSE needed when using rbind in R
1
1
Entering edit mode
7.4 years ago
AsoInfo ▴ 300

Greetings!

I am doing some analysis in R using sqldf package. The file contains SQL queries of OrthoMCL. It is working fine for the small files but with the larger files (Size of the file is 26 GB) it started to give me error:

Error in if (n > 0) c(NA_integer_, -n) else integer() :

missing value where TRUE/FALSE needed

Calls: rbind -> rbind -> structure -> .set_row_names

In addition: Warning messages:

1: In Make.row.names(nmi, ri, ni, nrow):

NAs introduced by coercion to integer range

2: In nrow + ni : NAs produced by integer overflow

I am unable to understand the rbind error. I looked at other question (Error with fdrtool in R ) having similar error but I couldn't figure it out. The code for rbind is written as follows:

BestHit2 <- list()
for (i in 1:length(args)){
  b <- read.table(args[i],sep="\t",header=T)
  BestHit2 <- rbind(BestHit2,b)
}

Any help would be appreciated!

OrthoMCL R SQL • 5.8k views
ADD COMMENT
3
Entering edit mode
7.4 years ago

What is the purpose of using rbind on list element? Probably you need BestHit2 as a data.frame?

From rbind/cbind help page

Take a sequence of vector, matrix or data-frame arguments and combine by columns or rows, respectively. These are generic functions with methods for other R classes.

ADD COMMENT
0
Entering edit mode

Yes, I need BestHit2 as a data frame.

ADD REPLY
2
Entering edit mode

Then initialize it as data.frame (eg. for 5 columns)

data.frame(matrix(nrow=0,ncol=5))

Also check that all the tables have same number of columns.

1: In Make.row.names(nmi, ri, ni, nrow):

NAs introduced by coercion to integer range

This makes me believe that some of the tables have no headers and you are trying to read the headers!

ADD REPLY
0
Entering edit mode

Yeah, I am doing it and so far it seems working. I'll update you further.

ADD REPLY
0
Entering edit mode

Yeah, I sorted everything you said and it is working fine now. Thanks!

ADD REPLY
0
Entering edit mode

Happy that it is resolved.

ADD REPLY
0
Entering edit mode

Can you please put your comment as an answer? So I can accept it. Thanks!

ADD REPLY
0
Entering edit mode

done that, thanks!!!

ADD REPLY

Login before adding your answer.

Traffic: 1624 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6