✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Query with sankey diagram using plotly and R

I ran this script using the sankey diagram documentation on plotly.
I wish to understand what does source and taget in the json file mean. Also, is it possible to replicate this diagram using ggplot2 and plotly.

library(plotly)
library(rjson)
json_file <- "https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/sankey_energy.json"
json_data <- fromJSON(paste(readLines(json_file), collapse=""))

p <- plot_ly(
type = "sankey",
domain = c(
  x =  c(0,1),
  y =  c(0,1)
),
orientation = "h",
valueformat = ".0f",
valuesuffix = "TWh",

node = list(
  label = json_data$data[[1]]$node$label,
  color = json_data$data[[1]]$node$color,
  pad = 15,
  thickness = 15,
  line = list(
    color = "black",
    width = 0.5
  )
 ),

 link = list(
  source = json_data$data[[1]]$link$source,
  target = json_data$data[[1]]$link$target,
  value =  json_data$data[[1]]$link$value,
  label =  json_data$data[[1]]$link$label
 )
 ) %>% 
 layout(
title = "Energy forecast for 2050<br>Source: Department of Energy & Climate Change, Tom Counsell via <a 
href='https://bost.ocks.org/mike/sankey/'>Mike Bostock</a>",
font = list(
  size = 10
),
xaxis = list(showgrid = F, zeroline = F),
yaxis = list(showgrid = F, zeroline = F)
)