Division between different dataframes

Viewed 18

i have a dataframe, that i want to filter. I want to filter it so that i will remove the columns with ratios between exp_cooccur and obs_cooccur are less than 0.05 (20%).

How can i do that?

> head(df)
  sp1 sp2 sp1_inc sp2_inc obs_cooccur prob_cooccur exp_cooccur    p_lt    p_gt
1   1   2      14      13          11        0.630        10.7 0.87941 0.57941
2   1   3      14      14          11        0.678        11.5 0.53529 1.00000
3   1   4      14      10          10        0.484         8.2 1.00000 0.05147
4   1   5      14      12          10        0.581         9.9 0.80882 0.67647
5   1   6      14       2           1        0.097         1.6 0.33088 0.97794
6   1   7      14      10          10        0.484         8.2 1.00000 0.05147
               sp1_name                sp2_name
1 Geospiza magnirostris         Geospiza fortis
2 Geospiza magnirostris     Geospiza fuliginosa
3 Geospiza magnirostris     Geospiza difficilis
4 Geospiza magnirostris       Geospiza scandens
5 Geospiza magnirostris    Geospiza conirostris
6 Geospiza magnirostris Camarhynchus psittacula
1 Answers

base R

subset(df, (exp_cooccur / obs_cooccur) > 0.05)

dplyr

dplyr::filter(df, (exp_cooccur / obs_cooccur) > 0.05)

(Neither changes the data here, perhaps it will in your full data.)

Related