Hei,
I am trying to get the minimal value of a column (ex: maximumDepthInMeters) corresponding for each different species available of the column NameSize, and I am interested of the result; the value of the column CarbonBiomass, per locationID and per expedition. (see example of my data below)
I have been trying this code from this post (Extract row corresponding to minimum value of a variable by group)
library(data.table)
DT <- data.table(depthint_5sp_Diatoms)
min_of_maxdepth <- DT[ , .SD[maximumDepthInMeters == min(maximumDepthInMeters)], by = NameSize]
But it doesnt work for what I want.
I have also tried : (not working, get of course same table)
min_value <- depthint_5sp_Diatoms %>%
group_by(NameSize, CarbonBiomass, locationID, expedition) %>%
slice(which.min(maximumDepthInMeters))
Example of my data: (I have more locationID (ex: P2,P3, etc) and more expedition (ex: 2019706))