[This article was first published on HighlandR, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
“`r
library(data.table)
library(dplyr)
library(tidyr)
library(networkD3)
library(htmlwidgets)
library(widgetframe)
data %
rename(failed = `Failed_supplier`,
acquired = `Acquired_by`) %>%
mutate(year_acquired = lubridate::year(Date)) %>%
relocate(year_acquired, .before = ‘Date’) %>%
select(-Date)
links %
filter(year_acquired >= 2021) %>%
mutate(row = row_number()) %>%
gather(‘column’, ‘source’, -row) %>%
mutate(column = match(column, names(data2))) %>%
group_by(row) %>%
arrange(column) %>%
mutate(target = lead(source)) %>%
ungroup() %>%
filter(!is.na(target))
links %
mutate(source = paste0(source, ‘_’, column)) %>%
mutate(target = paste0(target, ‘_’, column + 1)) %>%
select(source, target)
nodes
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
To leave a comment for the author, please follow the link and comment on their blog: HighlandR.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.