Does anyone have tips for good workflows between R and Google Docs? I do almost all my analysis in R and prepare my reports using RMarkdown. For almost everyone at my company, however, Google Docs documents & slides are the best way to share documents and receive comments. Currently, I'm exporting my RMarkdown documents by knitting into Word docs and importing into Google Docs. This is pretty clunky and has some formatting issues. Anyone have a better way?
Interesting question! I look forward to hearing some answers. I have done part of that - collaborating on a google doc and making figures in R. I used package googleDrive to upload png files, and then linked to those images in the google doc. When I rerun the scripts and update the image files on my google drive the images update in the doc.
Maybe pandoc can do md -> google doc?
@billR I've been playing around with this too in a package. You get less formatting issues if you convert to html before uploading.
One way I want to explore is: knit the .Rmd to .md using the imgur_upload()
function (like reprex uses), then pandoc the output .md to .html. This would preserve the images and hopefully not introduce too many formatting issues.
This is a cool approach. It sounds quite automatable!
this package looks very cool! I'm going to try it out! What problems does it have currently?
@billR The main problem is like the one you highlight. Markdrive
works well for pulling docs from Google Drive and making edits. But if you want to knit an .Rmd to Google Drive it uses the rmarkdown
package. rmarkdown
knits to some pretty heavyweight html that Google Drive doesn't interpret well. The other option is .docx but you know the issues there.
So something along the lines of what I was saying earlier is required. Or maybe someone else has a better idea. I'd be happy to hear it.
The html is all themeable so you could try with a lighterweight template. html_vignette()
would be one place to start since it was designed to generate a small html file suitable for embedding in R packages.
I also noticed https://github.com/ropenscilabs/gdoc which seemed to be the solution I'm looking for in knitting to google docs - but it's marked as abandoned. Does it no longer work, or is there an alternate package that achieves those aims?
That (https://github.com/ropenscilabs/gdoc) was an rOpenSci Unconf project (I was part of it).
There is no successor. Or rather the successor is the stuff you see in this thread, i.e. @milesmcbain's experiment.
The problem we ran into is that compiling .Rmd
to Google Doc is not that hard. But for the whole workflow to truly be useful, you then want to go the other direction. And that is really hard.
I've used a Google apps script to convert huge Google docs to markdown. I used it at work to move process documentation in Google docs to a markdown based wiki with pretty good success. It handled things like bullets and tables and images really well. It did not handle some font variation as sizing well, though. That said, I feel like it should be possible to automate adding and calling a bit of JavaScript like this on the Google doc to convert the text to a close enough option for using in Rmarkdown.
With the launch of the Google Docs API, are we looking at possibilities for improved connectivity from R? https://developers.google.com/docs/api/
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.