R rename duplicate col and rownames (subindexing)

前端 未结 1 924
耶瑟儿~
耶瑟儿~ 2021-02-20 14:59

I would very much appreciate if a kind soul could tell me how to do this in R:

Given a squared matrix with duplicated columns and rows, such as

       1          


        
1条回答
  •  一生所求
    2021-02-20 15:14

    You could use ?make.unique or ?make.names:

    v <- as.character(c(1, 1, 2, 2, 2, 2, 3))
    make.unique(v)
    # [1] "1"   "1.1" "2"   "2.1" "2.2" "2.3" "3"
    

    (You have to combine this with rownames and colnames.)

    0 讨论(0)
提交回复
热议问题