You asked how to transform your data.
This required me to generate your example data. The tribble is an example of how to communicate example data on the forum.
Here is a fully generic solution, again your own data would be in place of df.
library(tidyverse)
library(purrr)
df <- tibble::tribble(
~NAME, ~Collegue1, ~Collegue2,
"John Smith" , "Bill Gates", "Brad Pitt",
"Adam Sandler" , "Mary Lynn" , "John Smith",
"Bill Gates" , NA , "Adam Sandler",
"Brad Pitt" , "John Smith", "Bob Morriss"
)
contents <- map(names(df)[-1],~df[[.]])
all_names<- sort(unique(reduce(contents,c)))
df2<- df %>% mutate_at(.vars = names(df)[-1],
.funs = ~ as.integer(factor(.,levels=all_names)))