'How to replace every underscore after first with '/'

I have a data frame with one column of values:

df1$V1 = c("5325_214424", "63325_685_2436", "573_636", "5754_23523_214235", "5634_777_19_101")

I would like to keep only the first underscore in every row and replace any additional underscores with a slash. Some row values may or may not have additional underscores. So ideally I would like to end up with this:

df1$V1 = c("5325_214424", "63325_685/2436", "573_636", "5754_23523/214235", "5634_777/19/101")
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source