[R] How to select given row of conditionally subsetted dataframe?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Thu Oct 14 09:51:10 CEST 2021


Hello,
I have selected a subset of a dataframe with the vector syntax (if
this is the name):
```
> df[(df$Y>0.2) & (df$X<10),]
     Y                X
10 0.2200642 1.591589
13 0.2941828 1.485951
```
How can I select only the second row? I only managed to get the whole
of whole columns:
```
> df[(df$Y>0.2) & (df$X<10),2]
[1] 1.591589 1.485951
> df[(df$Y>0.2) & (df$X<10),][2]
     X
10 1.591589
13 1.485951
> df[(df$Y>0.2) & (df$X<10),][1]
     Y
10 0.2200642
13 0.2941828
```
Thank you



More information about the R-help mailing list