-2

I have a dataset with columns and rows and in that dataset I want to extract the minimum water potential value which i did by using the which.min() function which gave me the position of the element present in the data frame but other than that I want the species and the day for that value recorded which codes to use? I use something like this

f[which.min(f$water_potential),]

  • 1
    It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Sep 12 '22 at 15:26

1 Answers1

1

if I understand it correctly you have a data frame, say df, and which.min(df$water_potential) returns you the position of the observation with the minimum value. What happens if you try something like

df[which.min(df$water_potential),]

to retrieve the other column values for this observation?

Hauke L.
  • 291
  • 1
  • 8
  • Yeah thanks a lot that was helpful, but what if I just do which.min(df$water_potential) –  Sep 12 '22 at 15:35
  • It will return you the index of the observation (i.e. dataframe row) where the minimum is achieved. To make this more apparent, you could do it like this `i <- which.min(df$water_potential)`, `min_water_observation <- df[i,]` – Hauke L. Sep 12 '22 at 15:45