Skip to content
Prev 156299 / 398506 Next

Re adout row and column of a matrix value

Hello R users,

I want to readout the row and column postion from a certain matrix value
into a csv file.
I have only found this syntax 

"which(a == b, arr.ind = T)"

so I get

a = matrix

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]    1    1    2    2    2    1    1    2
[2,]    1    2    3    3    3    4    4    3
[3,]    3    3    3    5    5    6    5    4
[4,]    4    4    4    3    3    4    4    3
[5,]    3    4    5    3    3    3    2    2
[6,]    3    3    3    3    3    3    2    2
[7,]    2    2    2    2    2    4    2    1
[8,]    1    1    0    0    0    0    0    0
[1] 6
row col
[1,]   3   6

but I need row and col seperate for the csv file.

row <- c("code for row")
col <- c("code for col")
value <- c("6")

#dataframe

test <- data.frame(row, col, value)

write.csv................

Thanks.

Greets