Skip to contents

The connector.sharepoint package provides a convenient interface for accessing and interacting with Microsoft SharePoint sites directly from R. This vignette will guide you through the process of connecting to a SharePoint site, retrieving data, and performing various operations using this package.

This package is meant to be used with connector package, which provides a common interface for interacting with various data sources. The connector.sharepoint package extends the connector package to support Microsoft SharePoint sites.

Installation

You can install the connector.sharepoint package using the following command:

# Install from CRAN
install.packages("connector.sharepoint")

# Alternatively, you can install the development version from GitHub:
devtools::install_github("novonordisk-OpenSource/connector.sharepoint")

Usage

Package is meant to be used alongside connector package, but it can be used independently as well. Here is an example of how to connect to a SharePoint site and retrieve data:

library(connector.sharepoint)

# Connect to SharePoint
con <- ConnectorSharepoint(site_url = "sharepoint_url")

When connecting to SharePoint, you need to provide the URL of the SharePoint site. By default, token is retrieved from the AzureAuth package using get_token() function, or it can be provided by the user, and it is used to authenticate the user to the SharePoint site.

Example of how to use the connector object:

# List content
con |>
  list_content_cnt()

# Write a file
con |>
  write_cnt(iris, "iris.rds")

# Read a file
con |>
  read_cnt("iris.rds") |>
  head()

# Remove a file
con |>
  remove_cnt("file_name.csv")

Usage with connector package

Here is an example how it can be used with connector package and configuration YAML file (for more information take a look at the connector package):

# Connect using configuration file
yaml <- yaml::read_yaml(system.file("config", "example_yaml.yaml", package = "connector.sharepoint"), eval.expr = TRUE)

connector <- connector::connect(yaml)

# List content
connector$test |>
  list_content_cnt()

# Get SharePoint connection object
connector$test |>
  get_conn()

# Write a file
connector$test |>
  write_cnt(iris, "Test/iris.csv")

# Read a file
connector$test |>
  read_cnt("Test/iris.csv")

Contributing

We welcome contributions to the connector.sharepoint package. If you have any suggestions or find any issues, please open an issue or submit a pull request on GitHub.

License

This package is licensed under the Apache License.