rgoogle-apps-scriptgoogle-sheetsgooglesheets4

Is there a way to make some formatting in Google Sheet within R


I'm currently on a project aiming to generate some formatted report from R to google sheet.

Now I'm using googlesheets4 package and able to write data into google sheet from R. But is there a way to do some formatting work? like bold, italic, add $ sign or conditional formatting and etc.

Here is the example spread sheet I made.

https://docs.google.com/spreadsheets/d/1vp-w5muArvMxHKx4NL-39NMkAHRJCtldXLkUmJqKK2E/edit?usp=sharing

the output I want is like this(in sheet2), having $ in spend col, keep integer in kpi cols and conditional formatting on upsell cols

enter image description here


Solution

  • I ran into the same issue. I don't believe googlesheets4 has this type of functionality (yet at least.)

    The way I (quite inefficiently) worked around this was by creating two sheets, taking advantage of the fact that it is possible to format cells that have native/google sheets functions.

    The first spreadsheet contained the raw data imported from the R script, which could not be formatted. The second sheet was formatted to my liking, then collected the first sheet's data through functions.

    Hope this helps! I would have added this as a comment but I do not yet have the reputation to do so.