2

I'm trying to write an excel SUM formula to google sheet using R. I want to sum for example values A1 + A2 and save the formula for that in A3. The problem is that it should be a formula because I have a big GDoc with many updates

Using googlesheets4 it doesn't work because of leading apostrophe while pasting data (formula):

sheets_edit(
  gdoc_url,
  data = data.table('=sum(G6:G8)'),
  sheet = "wrk1",
  range = "A3",
  col_names = FALSE,
  reformat = TRUE
)

Do you have any solution for that in R or Python? I know that in openxlsx it is possible but it works only for MS excel..

zx8754
  • 52,746
  • 12
  • 114
  • 209
mario19088
  • 101
  • 6

1 Answers1

1

Finally I found a solution. In googlesheets4 R library is a function to formating text object to formula type.

dt[, fnct := paste0('=SUM(A2:A5)')]
dt$fnct <- sheets_formula(dt$fnct)

and then sheets_edit()

mario19088
  • 101
  • 6