The goal of {ibmsunburst} is to wrap the JavaScript library that IBM have produced for making sunburst personality insights charts for use in R and R Markdown documents.

Use with example data

The package contains a few examples JSON files corresponding to output from the API.

ibmsunburst::ibmsunburst(system.file(
  "extdata", "profiles",
  "en_v2.json", package = "ibmsunburst"
),
                           version = "v2")
ibmsunburst::ibmsunburst(system.file(
  "extdata", "profiles",
  "en_v3.json", package = "ibmsunburst"
),
                           version = "v3")

If you use the wrong version argument, then the widget will be blank.

Use with real data

The actual use of the package is to apply it on the output from IBM Personality Insight API. ibmsunburst::ibmsunburst() accept the data as list, JSON or path to file.

Say you have a text file of someone’s writing, called “sample.txt”. Here’s how you could query the API. There is no R wrapper for it… yet?

key = "your-key-not-this"
url = "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13"
uname="your-username-not-this"
pword="your-password"
library(httr)
cr=POST(url,
        authenticate(uname, pword),
        content_type("text/plain;charset=utf-8"),
        accept_json(),
        body=upload_file("sample.txt")
)
insightdata = content(cr)

The result is a list, that you can directly pass to ibmsunburst::ibmsunburst().

ibmsunburst::ibmsunburst(insightdata,
                         version = "v3")

Enjoy visualizing IBM Personality Insights!