Trying to figure out how to select particular subsets of a character string. I want to convert
"OTU_511><-><size=54><-><" to "OTU_511;size=54;"
I can successfully remove everything after the OTU ID using the following code:
gsub("([^>]*).*", "\\1", tree$tip.label)
However, it'd be great to replace those characters with ";" instead. Thanks for any tips you can provide.
If the pattern is consistently ><->< then you can use the following.
x <- "OTU_511><-><size=54><-><"
gsub("><-><", ";", x, fixed = TRUE)
# [1] "OTU_511;size=54;"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With