googlesheets4 | Google Spreadsheets R API ( reboot of the googlesheets | REST library
kandi X-RAY | googlesheets4 Summary
kandi X-RAY | googlesheets4 Summary
googlesheets4 provides an R interface to Google Sheets via the Sheets API v4. It is a reboot of an earlier package called googlesheets.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of googlesheets4
googlesheets4 Key Features
googlesheets4 Examples and Code Snippets
Community Discussions
Trending Discussions on googlesheets4
QUESTION
I am not able to able to authorize Google Sheet using Rstudio Server. I have tried all the possible ways available on google but it didn't work.
I'm using below code.
...ANSWER
Answered 2021-Apr-11 at 16:35I suspect that this is because you are loading both googlesheets
and googlesheets4
in one session. Please try following steps:
- Start a new environment on the server
- Load only
googlesheets4
then call gs4_auth() again.
If the error persist. Please tryto clean up the ~/.cache/gargle
folder which store the last authorization process and try again.
Please try clear up the cache and follow the step Here is what happen on my server:
QUESTION
Have a small dashboard. When the submit button is clicked there is no error, but there's also nothing written to the file.
The code looks like this:
...ANSWER
Answered 2021-Feb-27 at 19:58I believe your data frame 'submit' has to be first a reactive value or a placeholder for several values.
QUESTION
We are currently using google sheets for a research project on crowd forecasts for Covid-19 case and death numbers.
Google Sheets is used for convenience, but we are often running into quota limit issues - even though the number of users we have should be well below what Google allows.
I attempted to create a somewhat reproducible example by setting up a new google account and creating a sheet from which to read.
The first thing I tried (without making any changes to the google account) is this:
...ANSWER
Answered 2021-Feb-26 at 14:35Google says that it is a security measure. Try to share through adding their emails
QUESTION
I'm using the googlesheets4 package, which uses gargle for authentication. I have a scheduled script that runs regularly, so I need to set up non-interactive authentication. I tried following all the instructions I've found for setting up a service account token and using that to authenticate, but still can't seem to get it to work.
I created a service account token and stored it in a JSON file. I then used the following command:
...ANSWER
Answered 2021-Feb-09 at 17:07This is now resolved, with a response to a copy of this post on the googlesheets4
package's Github page!
Turns out, gs4_find
is actually a wrapper around googledrive::drive_find
. So in order to get the service token to work for this function, I'd need to authenticate with googledrive
, not googlesheets4
. There is even a whole article here about coordinating auth between googlesheets4
and googledrive
, if you're using both.
For my particular use case, I actually ended up just hardcoding the Google Sheet IDs into my script instead of using gs4_find
to do a name lookup, thereby avoiding use of googledrive altogether. Decided that's sufficient for my purposes.
QUESTION
I've got googlesheets4 working in a shinyapps.io with the following code:
...ANSWER
Answered 2020-Dec-01 at 13:06OK, pretty sure I've got this working...
It was the YouTube video here that really helped, and made this more clear.
All I need is a Service Account, which seems to generate a json file that I can upload with my app.
i.e. at around 1:03 in the video shows the creation of this service account, then adding that e-mail address (of the Service Account) to the Google Sheet(s) I want to access, this means I can download (using GoogleDrive) and write (using GoogleSheets).
The crazy part is that all I need to put in my code is the following:
QUESTION
I am a beginner of Shiny dashboard and I have a problem that bothered me a long time.
My final target is to assign data to a variable called "myData", but I give the users options to upload data either from local file or online file (in my case GoogleSheet).
Below is a simplified version of my app. To achieve the target, I did:
- Under the "data" tab, I create a selection box "input_option", so that the users can choose either uploading local data (="local") or data from a online persistent database (="online);
- I use "eventReactive" to source the data conditional on the value of "input_option";
- If the user chooses to upload the data from an online database, the data will be displayed in the dashboard body;
- If the user chooses to upload data from a local file, in the dashboard body, it will show the "fileInput" box to guide the user choose the local file. Then the data will also be displayed underneath in the dashboard body.
However, the problems are:
- In either way, the data cannot be displayed in the dashboard body. I don't even know if the data has been successfully sourced;
- When I choose to upload online data and then close the app, the R console does not pause but keeping running.
Could any friends or experts help me with the problems? I really really appreciate your help!
...ANSWER
Answered 2020-Aug-29 at 23:53Two changes in the server will make the local file work, and probably the googledrive one too.
QUESTION
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
...ANSWER
Answered 2020-Aug-08 at 00:17I 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.
QUESTION
I'm trying to download a specific tab from a google sheet to R, after trying gsheet package I only get the first tab, no matter how I change the sheetid.
I also try the library googlesheets4 to identify the sheet id but I got empty result, what did I do wrong? is there other way to complete this simple task? Thanks!
...ANSWER
Answered 2020-Aug-07 at 18:29Can't you use the function read_sheet()
from googlesheets4?
QUESTION
I am trying to read this googledoc via googlesheets4
.
The file contains 3 columns:
id
, as characterstart_date
/end_date
: this columns contain both dates (in the format2020-01-31
) and text strings (namely strings beingin_stock
andin_use
)
I made this googlesheet available to read with anybody with the link.
I read the dataframes as follows:
...ANSWER
Answered 2020-Jun-23 at 15:43try to do it this way (dplyr 1.0.0).
You have the text in_stock
and in_use
in the date column. Therefore, an error appears.
QUESTION
I know there are a few other similar questions floating around SO (e.g., here and here), but I thought I'd try again, as the others have not gotten many answers.
I have a Shiny app that allows its users to provide input through the app, but these users need to skip the authentication step. In the previous version of googlesheets
I made the sheet public (to anyone with the link) and avoided some of the authentication process. In updating to googlesheets4
I've run into permissions issues with deploying the updated app to shinyapps.io. Here is the summary of what I've tried, and what results I've gotten. Any pointers would be much appreciated.
First, based on the recommendations in this gargle
article I created a service account, downloaded a JSON service account token (with format "project-name-12345678abc1.json"), and have saved it (for now) in the parent app folder, under the assumption that it needs to be uploaded with the app bundle. Then I enabled the Google Sheets API.
I've put the following commands in the front of the app, ahead of anything substantial:
gs4_deauth()
, since the google sheet is public to anyone with the link and therefore might not require a token.Following this article,
gs4_auth(path = "project-name-12345678abc1.json")
. I've also added thescopes
argument (as below), anduse_oob=TRUE
.credentials_service_account(scopes = "https://www.googleapis.com/auth/spreadsheets", path = "project-name-12345678abc1.json")
.credentials_app_default(path = "project-name-12345678abc1.json")
Results
Most combinations give me errors saying "Can't get Google credentials" and then advising that I look at the non-interactive article on the gargle site. The one exception is Attempt 3, which provides the following error message instead - strangely promising:
Warning: Error in : Client error: (403) PERMISSION_DENIED
- Client does not have sufficient permission. This can happen because the OAuth token does not have the right scopes, the client doesn't have permission, or the API has not been enabled for the client project.
Any ideas on what I might be missing? The app works fine locally.
Any help is appreciated. Thanks!
...ANSWER
Answered 2020-Sep-07 at 21:29This problem has been addressed using the approach identified in this (closed) Github issue.
The key is to follow these steps exactly:
- Call
gs4_auth(cache = ".secrets")
once, running the app locally in the browser. - Substitute the line above with
gs4_auth(cache = ".secrets", email = TRUE, use_oob = TRUE)
. - Deploy the app to shinyapps.
I also cleared the previous tokens I had saved, which might have been important, though hard to know.
As noted in the Github discussion, including use_oob = TRUE
is probably not necessary. Additionally, this approach is detailed in the non-interactive auth article on the gargle site.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install googlesheets4
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page