Community docs

R and R Studio

The data.world R package makes it easy to query datasets and use data.world's REST API.

Install and configure the data.world R package.

Using an R console (like R Studio), you can use the data.world R package to run queries, import datasets, upload data, and more.

Install the data.world package for R:

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

Note

Note: You will need to have the devtools package for R installed to run the previous command. If that is not already installed, you can install it from CRAN using the command install.packages("devtools")

R_1.png

Configure the package with your API token.

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

R_2.png

View the Quickstart vignette to view more information on the data.world package.

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

R_3.png

Import your first query.

Using the data.world package, import your first query:

  1. Choose your dataset and retrieve your SQL or SPARQL query.

    Note

    The below query includes specific query parameters. You can also simplify your query by using SELECT * FROM DataDotWorldBBallTeam

  2. 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)
    R_4.png
  3. Use the available functions to begin modeling your data.

What next?

Here are some things you can do with R and data.world:

  • Use the Addins menu to quickly add a new Insight to data.world from R Studio.

  • Use the included dwapi package to update datasets, upload files, list all tables in a project, and more.