if (interactive()) {
# Example data: Source -> Port -> Destination with volumes
SupplyChain <- data.frame(
Source = c("China","China","China","Germany","Germany",
"Brazil","Brazil","USA","USA"),
Port = c("Los Angeles","Seattle","Houston","New York","Baltimore",
"Miami","Houston","Los Angeles","Miami"),
Destination = c("Portland","Chicago","Dallas","Boston","Philadelphia",
"Atlanta","Dallas","San Francisco","Atlanta"),
Volume = c(320,180,150,220,130,200,100,170,140)
)
# 3-stage: Source -> Port -> Destination (unquoted names)
Flows(Volume, Source, Port, Destination, data = SupplyChain)
# 2-stage: Source -> Port (sources colored; ports gray)
Flows(Volume, Source, Port, data = SupplyChain)
# All nodes neutral gray (flows still color by source)
Flows(Volume, Source, Port, Destination, data = SupplyChain,
nodes_gray = TRUE, link_alpha = 0.6)
# Supply a specific range (overrides theme), show one decimal in hover
Flows(Volume, Source, Port, Destination, data = SupplyChain,
fill = "blues", digits_d = 1)
}
Run the code above in your browser using DataLab