make.names(names, unique = FALSE, allow_ = TRUE)
names | a character vector. |
unique | a logical flag. TRUE if the resulting set of names should be unique; otherwise, FALSE (the default). |
allow_ | a logical flag. TRUE (the default) if the underscore character is allowed to appear in names. If FALSE, the underscore character is converted to a period, like other non-name characters. |
make.names(c("abc","ab??","1abc", "")) # [1] "abc" "ab.." "X1abc" "X"make.names(rep("A",5)) # [1] "A" "A" "A" "A" "A" make.names(rep("A",5), unique=TRUE) # [1] "A" "A.1" "A.2" "A.3" "A.4"
make.names(c(rep("A",5), "A.3"), unique=TRUE) # [1] "A" "A.1" "A.2" "A.4" "A.5" "A.3" # note that the fourth element becomes "A.4", # since "A.3" already exists
make.names(rep("",5), unique=TRUE) # [1] "X" "X.1" "X.2" "X.3" "X.4"
make.names(c("_A","A_","_")) # [1] "X_A" "A_" "X_" make.names(c("_A","A_","_"), allow_=FALSE) # [1] "X.A" "A." "X."
make.names(c("for", "function")) # [1] "for." "function."