0

I'm an R novice, so I can't make a sample data frame for you, for which I apologize. However, I'm doing bacterial community analysis and I have a table that has species for each column and each sample for each row. Each column is an identifier for each species. Within the data frame is the species abundance for each sample. My goal is to identify the most abundant species (column) for each sample (row). I think making a data frame that has samples (rows) with the most abundant species column identifier would be the most useful! Iterations I've tried (using phyloseq package, but can be used without this package).

beagle <- names(sort(taxa_sums(top.pdy.phyl),T, function(x) which(max==x)))
beagle2 <- names(taxa_sums(top.pdy.phyl),T, function(x) colnames(which.max(top.pdy.phyl))))

Any help would be appreciated! Thank you!

Samaj Oruel
  • 17
  • 1
  • 5

1 Answers1

0

How about:

names(top.pdy.phyl)[ apply(top.pdy.phyl, 1, which.max) ]

and

apply(top.pdy.phyl, 1 , max)
Robert Davy
  • 866
  • 5
  • 13
  • this wasn't exactly what I was hoping for, but was able to add a few more command and work with it to get what I needed. It was totally helpful! Thanks! – Samaj Oruel Nov 18 '17 at 04:04