Render Issues for R Markdown HTML Output to Sharepoint

So I’ve finished a lovely R Markdown script with an HTML output and was excited to share the analysis to colleagues internally, by sharing the Sharepoint link.

The output works fine when I open the HTML file directly on my machine. But for whatever reason, when I share or view via the Sharepoint link, simple things like the TOC, plotly graphs and leaflet maps do not render.

Here’s an example of the problem I’m running into, with some really basic script just as an example.

---
title: "Test_Output"
output: 
  html_document:
    toc: true
    toc_float: true
    
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown
Hello, this is a test.

## Test
```{r test plotly, echo = FALSE, warning = FALSE, message = FALSE}
library(plotly)
plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
```

And so this is the output, right.

enter image description here

But when I share the link (something like this https://mycompany.sharepoint.com/:f:/s/mydepartment/EvLlZjmxOetc) or if someone were to try and just navigate to the page on our Sharepoint, the output is all messed up. It looks like this: plots and TOC and maps do not render.

enter image description here

If anyone can help me to figure out how to allow my Markdown HTML output to render instantly once I share the link, that would be incredible, and I would feel like all my work on the script was not in vain!

I’ve tried adding “download=1” to the end of the URL, which indeed gives users an ability to view the output correctly by clicking the link and downloading the HTML, but this is not optimal as this is supposed to be a live product that I will continue updating.

Thanks! C