I tried the 2 ways below and it seems that whatever I do, a dot is added at the end of the name of the column "repeat":
df <- data.frame(col1=1:5,col2=6:10,"repeat"=11:15)
df <- data.frame(col1=1:5,col2=6:10,`repeat`=11:15)
df
Is there a way to do force it? Thanks!
After inspecting > data.frame
, I found the solution (avoid that the names are checked):
df <- data.frame(col1=1:5,col2=6:10, 'repeat' = 11:15, check.names=FALSE)
df
## col1 col2 repeat
## 1 1 6 11
## 2 2 7 12
## 3 3 8 13
## 4 4 9 14
## 5 5 10 15
An alternative is renaming of the wrongly named df:
df <- data.frame(col1=1:5,col2=6:10, "repeat" = 11:15)
names(df) <- c("col1", "col2", "repeat")
df
## col1 col2 repeat
## 1 1 6 11
## 2 2 7 12
## 3 3 8 13
## 4 4 9 14
## 5 5 10 15