如何修改此内容,以便添加_
(下划线)代替.
(点)作为其默认值。
> 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"
答案 0 :(得分:8)
您可以将make.names
与gsub
:
gsub("\\.", "_", make.names(c("a and b", "a-and-b"), unique = TRUE))
# [1] "a_and_b" "a_and_b_1"