I have the following data frame:
Gene <- c(1,2,3,4,5,6)
A1.1 <- c(1,1,2,4,3,5)
B1.1 <- c(2,1,4,2,4,5)
C1.1 <- c(2,4,3,2,1,5)
A1.2 <- c(1,1,2,3,4,5)
B1.2 <- c(2,2,3,4,5,1)
C1.2 <- c(3,3,2,1,4,5)
df <- data.frame(Gene, A1.1, B1.1, C1.1, A1.2, B1.2, C1.2)
df
Gene A1.1 B1.1 C1.1 A1.2 B1.2 C1.2
1 1 1 2 2 1 2 3
2 2 1 1 4 1 2 3
3 3 2 4 3 2 3 2
4 4 4 2 2 3 4 1
5 5 3 4 1 4 5 4
6 6 5 5 5 5 1 5
How can I remove the ".1" and ".2" (or the 3rd and 4th character) from each column header? (ex, A1.1 -> A1 or A1.2 -> A1). Could I use gsub()
?