Assuming I have data as shown below.
On all these data in general, I have 3 * A, 2 * B, 2 * C and only 1 D, E and F.
data <- read.table(textConnection("
col1 col2
A B
A C
B A
C D
E F
"), header = TRUE)
What I want to do is keep order and content, but make them unique. For example, A becomes A.1, A.2, and A.3.
col1 col2
A.1 B.2
A.2 C.2
B.1 A.3
C.1 D
E F
Is there any smart way to do this?
I know that I can use make.uniqueor make.names, but it seems that it can work for only one column, and not for the entire data set.
source
share