2

I have a PDF files and It have tables like this ( just metaphor)

      American | Asian | African | European | Middle
      Animals  |       | Animals | pottery  |  East
               | tree  | Flying  |  fragile | 
2010     2         6        19         12        14
2011     3         5         9          9        20
2012     9         2        14          0         1

When I extract this table with PDFtools or tabulizer packages, then the packages extract this line by line.

So the result for first row is

American Asian African European Middle \r\n Animals  Animals pottery East \r\n  tree Flying fragile \r\n

But what I want to is extract right this

American Animals Asian tree African Animals Flying European pottery fragile Middle East

Is there any method to extract right this?

Also by chance I noticed that when I drag and copy then paste this table to Window notepad then the notepad reads it magically like this;

American Animals Asian tree African Animals Flying European pottery fragile Middle East

So I think make some code which automatically paste table to notepad then recopy it to R so directly put it in to some variable. I also want to know how can realize this in R coding.

zx8754
  • 52,746
  • 12
  • 114
  • 209
user13232877
  • 205
  • 1
  • 9
  • Something like `x <- scan(text = 'American Asian African European Middle \r\n Animals Animals pottery East \r\n tree Flying fragile \r\n', what = character())`? I have tested with the string as posted, you would pass the first row of your data set. – Rui Barradas Apr 22 '20 at 15:17
  • I tried your reply and the result is the first case : [1] "American" "Asian" "African" "European" "Middle" "Animals" [7] "Animals" "pottery" "East" "tree" "Flying" "fragile" That's what I don't want. what I mean is to change this [1] "American" "Animals" "Asian" "tree" "African" "Animals" [7] "Flying" "European" "pottery" "fragile" "Middle" "East" Some sequence like this. – user13232877 Apr 22 '20 at 15:23
  • are you trying to remove the `\r\n` or are you trying to read in the data as a table? – Daniel O Apr 22 '20 at 16:36
  • I just want latter, read in the data as a table. – user13232877 Apr 22 '20 at 22:30

0 Answers0