4

我如何修改它以添加_(下划线)代替.(点)作为其默认值。

> 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"
4

1 回答 1

8

你可以make.names附上gsub

gsub("\\.", "_", make.names(c("a and b", "a-and-b"), unique = TRUE))
# [1] "a_and_b"   "a_and_b_1"
于 2013-08-07T17:34:44.690 回答