How can I modify this so that it add _
(underscore) in place of .
(dot) as its default value.
> make.names(c("a and b", "a-and-b"), unique = TRUE)
[1] "a.and.b" "a.and.b.1"
I am looking for the following result
"a_and_b" "a_and_b_1"
You could enclose make.names
with gsub
:
gsub("\\.", "_", make.names(c("a and b", "a-and-b"), unique = TRUE))
# [1] "a_and_b" "a_and_b_1"
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