0

I have extracted tables from pdf file with tabulizer package. After extracting tables I want to rbind different tables extracted as list with different length.

 table1 <- extract_tables("\\AC002_2017.pdf")

 final <- do.call(rbind, table1)

But it gives me following error

 Error in (function (..., deparse.level = 1)  : 
 number of columns of matrices must match (see arg 2)

How can I rbind it?

Format of data is as follows

 [[1]]   [,1]   [,2]   [,3]   [,4]

 [1,]    20     45     34      34 
 [2,]    23     34     67      43
 [3,]    22     23     42      34
 [4,]    45     44     56      54
 [5,]    12     11     12      14
 [6,]    34     33     45      32
Neil
  • 7,937
  • 22
  • 87
  • 145
  • 1
    What is the structure of `table1`? What is the structure of the expected output? Since it doesn't seem to be a matrix or dataframe, it isn't clear why `rbibd` is relevant. Did you try `as.list(table1)`? – John Coleman Jun 10 '18 at 11:25
  • Also, if they have different column counts, how do you want them rbound? According to some key, or just fill in NAs to the end? – Surak of Vulcan Jun 10 '18 at 11:28
  • Fill NAs to the end – Neil Jun 10 '18 at 11:29
  • @JohnColeman Every page is extracted as list,4 pages have 26 rows and 4 pages have 48 rows,that's where the problem is. – Neil Jun 10 '18 at 11:38
  • 1
    Maybe, try my answer [to this post](https://stackoverflow.com/questions/3402371/combine-two-data-frames-by-rows-rbind-when-they-have-different-sets-of-columns/46635610#46635610). – lmo Jun 10 '18 at 12:41
  • I extract the data as `data.frame` and then use `merge(..., all = T, fill = T)` with a `do.call` instead. Give it a shot if `rbind` is troublesome. – Gautam Jun 11 '18 at 20:48

0 Answers0