Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 446

How to replace and delete different underscore in a single name row

$
0
0

Let's suppose I have this situation

data = data.frame('A' = c('A_A_', 'B_B_'))

A_A_ where I would like to remove the final and replace the central underscore. What can I do to save the following two steps?

data %>%   mutate(A = sub("_$","", A)) %>%   mutate(A = sub("_","->", A))

Thanks


Viewing all articles
Browse latest Browse all 446

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>