Hi Chris82, Try this:
res=c(which(a == max(a), arr.ind = T),max(a)) names(res)=c('row','col','value') write.csv(res,"C://yourfile.csv",row.names=TRUE) HTH, Jorge On Wed, Sep 17, 2008 at 1:47 PM, Chris82 <[EMAIL PROTECTED]> wrote: > > 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 > > > print(max(a)) > [1] 6 > > which(a == max(a), arr.ind = T) > 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 > > -- > View this message in context: > http://www.nabble.com/Readout-row-and-column-of-a-matrix-value-tp19537540p19537540.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.