I've imported the data from a text file and the negative numbers are in the form of 100- (The minus sign in the right side) and I should convert it into -100. Any idea. Thanks in advance.
How to move minus sign from right to left/back to front in R?
1.9k views Asked by Hanif Ansari At
1
We can do this using
sub
. We capture the numbers as a group ((\\d+)
) followed by a-
at the end ($
) of the string and replace with-
followed by the backreference (\\1
) of the capture group.data