Keeping Exclamation synbol in column names (Header)

Hello Friends.
I have an issue about using Special Character in Column Names(Header).
In this case I have some columns names that start with "!", and this exclamation is being replaced by "X.". I tried to fix it, by using check.names = False but it did not work. Any suggest?

MatrixGD<- data.frame(read.csv(file = "Unite_Data.txt", header = TRUE, sep = "\t", check.names = FALSE, row.names = 1 ))

sdddddd

I want to keep !1XSMTW25415, !.....

You can use the following R code.

MatrixGD <- read.csv(file = "symbol_in_name.csv", 
                     header = TRUE, sep = ",", check.names = FALSE)
MatrixGD
colnames(MatrixGD) <- gsub("[?]","",colnames(MatrixGD))
MatrixGD

MatrixGD$`!1XSMTW25415`

output

> MatrixGD
          ?!1XSMTW25415 ?!1XSMTW25416
1 !12abc1             1             2
2 !12abc2             3             4
3 !12abc3             5             6
> colnames(MatrixGD) <- gsub("[?]","",colnames(MatrixGD))
> MatrixGD
          !1XSMTW25415 !1XSMTW25416
1 !12abc1            1            2
2 !12abc2            3            4
3 !12abc3            5            6
> 
> MatrixGD$`!1XSMTW25415`
[1] 1 3 5

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.