It is correct behavior, even though it’s not very intuitive.
The logic is that first “." matches all characters it finds and replaces them with “abcx”. Then it sees that nothing is left – but since ".” matches any character zero or more times, “nothing” is a valid match: it’s any character zero times. Therefore it replaces the “nothing” at the end with “x”, which causes you seeing two x’s in the end result.
“^.*$” is a good fix, or if R is never an empty string, “.+” works too (replace one or more characters so “nothing” is not a match anymore).