Learn R Programming

data.world-r

The data.world package is the main R package for working with datasets on data.world.
Using this packages users can:

  • Query and join datasets
  • Choose between SQL and SPARQL
  • Publish insights
  • Use data.world's REST API (via included dwapi package)

Getting Started

To get started, load the library and checkout the quickstart vignette.

library(data.world)
vignette("quickstart", package = "data.world")

Here is a simple example:

intro_ds <- "https://data.world/jonloyens/an-intro-to-dataworld-dataset"

sample_query <- data.world::qry_sql(paste0(
  "SELECT t.Name, t.Height, s.AssistsPerGame ",
  "FROM DataDotWorldBBallTeam as t ",
  "JOIN DataDotWorldBBallStats as s ON t.Name = s.Name ",
  "ORDER BY s.AssistsPerGame DESC"))

data.world::query(sample_query, dataset = intro_ds)

Notice that dataset is parameter required by most functions and can be provided in two formats:

  1. URL: "https://data.world/jonloyens/an-intro-to-dataworld-dataset"
  2. Path: "jonloyens/an-intro-to-dataworld-dataset"

Publishing Insights

For your convenience, this package allows you to publish insights to data projects without leaving R Studio.

Using R Studio's "Addins" menu, look for DATA.WORLD > New insight.

The add-in will automatically capture the active plot in R Studio's plot view and give you the opportunity to quickly choose the project, and enter title and description for your insight.

Installation

To get the current released version from CRAN:

install.packages("data.world")

To get the current development version from GitHub:

devtools::install_github("datadotworld/data.world-r", build_vignettes = TRUE)

Configuration

First, users must obtain an API authentication token at: https://data.world/settings/advanced

IMPORTANT: For your security, do not include your API authentication token in code that is intended to be shared with others.

Configuration can be provided in 3 forms:

  • Via config file
  • Via environment variables
  • At runtime

Config files are the most convenient configuration method. Once saved configuration will be automatically restored when data.world is loaded.

From the R console:

saved_cfg <- data.world::save_config("YOUR API TOKEN")
data.world::set_config(saved_cfg)

For additional configuration options, see ?set_config

Next

Check out the quickstart and query vignette and the package documentation (?data.world).

> vignette("quickstart", package = "data.world")
> ?data.world

Copy Link

Version

Install

install.packages('data.world')

Monthly Downloads

10

Version

1.2.2

License

Apache License 2.0

Issues

Pull Requests

Stars

Forks

Maintainer

Rafael Pereira

Last Published

April 4th, 2018

Functions in data.world (1.2.2)

cfg_saved

Construct configuration object using file-based configuration.
data.world

data.world: The main R package for working with data.world datasets.
cfg_env

Construct configuration object using environment variables.
data.world-defunct

Defunct function(s) in the data.world package
insight_project_filter

Filter the specified list of projects to those suitable for selection in the add-in
configure_package

Apply configuration from file or envvars and load dwapi
is_attached

Determine if library is already attached
extract_dataset_key

Extract the dataset key from URL or as provided.
query

Execute a query on data.world.
save_config

Save configuration to file in the user's home directory.
set_config

Apply configuration to current R session.
add_insight_addin

Driver function for data.world Insight Add-in
sdk_version

Return the current data.world version.
cfg

Construct configuration object using runtime values.
save_image_as_insight

Save an image file as a data.world insight
user_agent

Return the data.world user-agent.
qry_sql

Constructor function for SQL queries.
qry_sparql

Constructor function for SPARQL queries.