0

I started to fill some measurement data (that accumulated over a long time) into a table of an OpenOffice Writer document (saved as ODF), originally solely for documentation purposes.

Now I had the idea to process the data in the table with R, wondering how I could elegantly get the table data into R. The table is several pages long...

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
U. Windl
  • 3,480
  • 26
  • 54
  • does this for `docx` files. I don't have OpenOffice Writer (and it's a giant install IIRC) so if you can provide a sample of one with a table in it, I can likely modify said package to accommodate it since they [look similar](https://en.wikipedia.org/wiki/OpenDocument_technical_specification). Alternatively, save your document as a `docx` and try that package. – hrbrmstr Aug 04 '17 at 10:54
  • also maybe package [rio](https://cran.r-project.org/web/packages/rio/rio.pdf) worth checking out? if you saved your data neatly and consistently (e.g. always comma separators...) you could just `read.delim()` from a text connection or saved in a simple text file? if you could post some sample date it will be easier – davidski Aug 04 '17 at 11:27
  • @hrbrmstr: The link you gave does not work. Please don't copy some material you haven't tried yourself! – U. Windl Aug 04 '17 at 11:39
  • @davidski: If I already have the data as CSV, I don't need any further instructions. I was thinking something like copy the table into the clipboard and then extract the data from there. I know it works with Excel/Calc, but I don't know about Writer. – U. Windl Aug 04 '17 at 11:42
  • 1
    @U.Windl all you had to do was remove a trailing `>`. https://github.com/hrbrmstr/docxtractr (given your reply, it's unlikely I'll dedicate any time to modify the package). You can also pull it directly from CRAN, but it seems you didn't even look up the pkg name there, either. – hrbrmstr Aug 04 '17 at 12:23
  • @davidski: Sorry, I didn't look close enough to the URL. – U. Windl Aug 07 '17 at 08:15

1 Answers1

0

Considering the dependencies of docxtractr suggested by @davidski, I tried a different approach that worked:

  1. Mark the table in Writer (via Table->Select->Table), then Copy (^C).
  2. Open Calc, then paste (^V) the table. Mark the table (clicking in upper left corner), then copy it (^C).
  3. Use read.table(file="clipboard", header=TRUE, sep="\t") in R to get the table data.

Note: Step 2 is necessary, because otherwise the resulting data frame is not correct.

U. Windl
  • 3,480
  • 26
  • 54
  • just a note - `docxtractr` was suggested (and written) by Bob (@hrbrmstr) - not me. he's an bottomless well of knowledge when it comes to R – davidski Aug 08 '17 at 09:01