tidyverse / googlesheets4

Google Spreadsheets R API (reboot of the googlesheets package)
https://googlesheets4.tidyverse.org
Other
360 stars 53 forks source link

Datatype issue get a single quote on all numeric based cols #228

Closed featherduino closed 1 year ago

featherduino commented 3 years ago

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex. Special tricks for this package are in How to create a googlesheets4 reprex.

Brief description of the problem

# insert reprex here
gs4_create(name="LI_Q",sheets = LI_dataset)

Hi

Loaded a csv and did some inner join transformations with it and pushed the dataset via gs4_create() On trying to pivot on that data noticed there was a single quote at the beginning of every numeric col wasted a lot of time on this

jennybc commented 3 years ago

I don't have LI_dataset. Only you do.

featherduino commented 3 years ago

ofcourse why would you ? You would not even have mail id synced to my drive ...

cpilat97 commented 3 years ago

Before you run

gs4_create(name="LI_Q",sheets = LI_dataset)

I'd recommend checking all your column structures & their type using something like

str(LI_dataset)
glimpse(LI_dataset)

and see if any of them are actually character types even if you think they were numeric when you read in the csv. I've had this happen to me before and it's always been because at some point during mutates, joins, data manipulation, I convert a numeric column to character and google sheets adds that single apostrophe in to denote the character value (I've also ran into this when strictly using google sheets and not using R at all).

When i've gone back to my code and specifically set my numeric columns to numeric (using as.numeric()) and then re-upload to sheets, the problem has gone away.

jennybc commented 2 years ago

@cpilat97's troubleshooting advice is solid.