my matrix is like this-
13367*13367
long matrix-
NBAS DNAH9 NRAS NRAS TP53 TP53 TP53 SCYL2 RNF19A
NBAS 1 0 0 0 0 0 0 0 0
DNAH9 0 1 0 0 0 0 0 0 0
NRAS 0 0 1 0 0 0 0 0 0
NRAS 0 0 0 1 0 0 0 0 0
TP53 0 0 0 0 1 0 0 0 0
TP53 0 0 0 0 0 1 0 0 0
TP53 0 0 0 0 0 0 1 0 0
SCYL2 0 0 0 0 0 0 0 1 0
RNF19A 0 0 0 0 0 0 0 0 1
I need to extract all pairs of rows and column headers for which the value is equal to 1 . I m using the following R script-
Pmatrix = read.csv ("file.csv", header= TRUE, row.names = 1)
sig_values <- which(Pmatrix==1, arr.in=TRUE)
cbind.data.frame(colIDs = colnames(Pmatrix)[ sig_values[, 1] ],rowIDs = rownames(Pmatrix)[ sig_values[, 2] ])
but getting error-
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
duplicate 'row.names' are not allowed
If I will put row.names = False
R will assume no rownames and add numbering instead. But i need the row names and column names not the numbers.