How to connect RStudio using Shiny to Microsoft 365 - r

I have a lot of googlesheets that i write in and out from using R. We are merging our sheets into Office online(365).
How can i connect to the online microsoft services (365) from R, especially Excel.
I currently use library(googlesheets) to connect via R.
I will also in instances write some of the current googlesheet data out to the Shiny server using R. I'm looking for some advice and can this be done.
Thanks

You can use the AzureGraph R package by Microsoft (documentation) to get a token via your active directory. Then use the Graph API (documentation) with the call_graph_url function from AzureGraph.
I had issues downloading via the API call, so I used the httr GET function and readxl package once I was able to find the graph download URL:
GET(item[["#microsoft.graph.downloadUrl"]], write_disk(tf <- tempfile(fileext = ".xlsx")))
df <- read_excel(tf)

Per 2022, there is a new (official) package in play that will suit your needs:
https://github.com/Azure/Microsoft365R

Related

Is it possible to download software using R?

I am writing a user-friendly function to import Access tables using R. I have found that most of the steps will have to be done outside of R, but I want to keep most of this within the script if possible. The first step is to download a Database driver from microsoft: https://www.microsoft.com/en-US/download/details.aspx?id=13255.
I am wondering if it is possible to download software from inside R, and what function/package I can use? I have looked into download.file but this seems to be for downloading information files rather than software.
Edit: I have tried
install_url(https://download.microsoft.com/download/2/4/3/24375141-E08D-
4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_X64.exe)
But I get an error:
Downloading package from url: https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_X64.exe
Installation failed: Don't know how to decompress files with extension exe

Connecting to Cassandra Data using Sparklyr

I am using RStudio. Installed a local version of Spark, run a few things, quite happy. Now I am trying to read my actual data from a Cluster, using RStudio Server and a standalone version of Spark. Data is in Cassandra, and I do not know how to connect to it. Can anyone point me to a good primer on how to connect and read that data?
there is a package called crassy and is listed on the official sparklyr site's under Extensions. You can search for crassy in GitHub.

Running R script on hadoop and mapreduce

I have an R-script that does stuff with a bunch of tweets and I would like to use the same script on the same data but saved in an Hadoop file system. According to this Hortonworks tutorial I could use R code with data from my HDFS, but it is not quite clear.
Can I use the very same R-script, taking advantage of the mapreduce paradigm, by using this Revolution R? Should I change my code or is there a way to execute the same functions optimized for an Hadoop architecture?
My wish would be to write my code on a standard R IDE like R-Studio and then use it, or use the most of it, on my cloud services (such as Microsoft Azure) with mapreduce on the base.
Yes, you can run any R script across different data platform from Hadoop to Spark to Teradata and SQL Server by using environment specific compute context.
Following two links should help you get started on how to use Revolution R / Microsoft R Server on Hadoop:
https://msdn.microsoft.com/en-us/microsoft-r/scaler-hadoop-getting-started
https://github.com/Azure/Azure-MachineLearning-DataScience/blob/master/Misc/MicrosoftR/Samples/NYCTaxi/NYC2013_MRS_LinearBinary.Rmd

Error: oauth_listener() needs an interactive environment

Using Shiny and R to create a little webapp that pulls data from Google BigQuery and spits it out onto the page. Uses the bigrquery package
When running the script from inside R (source(x.R)) everything runs fine, however when using Rscript x.R I get the error. I'm trying to setup cron to run the script automatically.
There is a .httr-oauth file in the directory of the script.
This question is similar to another one I answered where I suggested using a Google Service Account for server-to-server authentication using the googleAuthR and bigQueryR packages for R. Please refer to that answer (via the above link) for details including an example R script.
In the end I've decided to just use python to pull data from bigquery and use it in R.

How to download google docs spreadsheet through R

I would like to download a google docs spreadsheet using R and then import the spreadsheet as a csv file in a small shiny server app.
How could I do that?
Try the new googlesheets package, which is an R API for Google Sheets:
https://github.com/jennybc/googlesheets
This snippet will install the package, copy a Sheet to your Google Drive, register it for access, and import data from one tab or worksheet into a local data.frame:
devtools::install_github("jennybc/googlesheets")
gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
copy_ss(key = gap_key, to = "Gapminder")
gap <- register_ss("Gapminder")
oceania_csv <- get_via_csv(gap, ws = "Oceania")
As for integration with Shiny, see the shinyga package which recently incorporated support for googlesheets:
https://github.com/MarkEdmondson1234/shinyga
You can use RGoogle Docs package to access the Google Docs content. Other option worth consider is the RGoogle Data package that provides access to Google services.

Resources