When importing data from a file with column headers where the data items are tab-delimited, the environment RStudio automatically replaces space between strings to dot, although the correct variable names are Species names containing a space and possibly other characters.
When outputting final reports, the correct spelling of species names is critical. I need to replace the dots with spaces. However, the str_replace function does not change the dots.
name_i<-str_replace(all_names[[i]], ".", " ")
Removes the first character in the name, instead of replacing the dots in the middle of the name:
"Genus.species" --> " enus.species"
name_i=str_replace_all(name_i, ".", " ")
Removes all characters in the name, instead of replacing the dots in the middle of the name:
"Genus.species" --> " "
This behavior is similar to that of a regular expression, but escaping "\." also does not work, so this is not a regular expression.
In general, I would like to solve this problem not for printing, but in general, because scientific names of variables (Species) often contain dots and other symbols.
For example:
"Bembidion mannerheimii C. R. Sahlberg, 1827"
"Genus species subspecies (N. Fam., 2000)"
ps. It is strange that they decided to implement the code this way, instead of creating auxiliary alphanumeric variable names.