在数据框中查找值并返回值

时间:2019-10-26 20:54:29

标签: r dataframe search matrix lookup

我不确定为什么我很难找到应该是一个简单问题的答案。我有以下数据框:

> test
     Month        Equity - Rank FI - Rank Alts - Rank Reweight
[1,] "2006-01-31" "1"           "3"       "2"         "No"    
[2,] "2006-02-28" "1"           "3"       "2"         "No"    
[3,] "2006-03-31" "1"           "3"       "2"         "No"    
[4,] "2006-04-28" "1"           "3"       "2"         "No"    
[5,] "2006-05-31" "2"           "3"       "1"         "No"    
[6,] "2006-06-30" "1"           "3"       "2"         "No"    
[7,] "2006-07-31" "2"           "3"       "1"         "No"    
[8,] "2006-08-31" "1"           "3"       "2"         "No"  

我要做的就是按“月”搜索并返回该行的值。

我一直在尝试以下操作,但一直没有得到任何结果:

test[test$Month == '2006-03-31',]
# A tibble: 1 x 5
  Month               `Equity - Rank` `FI - Rank` `Alts - Rank` Reweight
  <dttm>                        <dbl>       <dbl>         <dbl> <chr>  

有人可以帮我弄清楚我在做什么错吗?谢谢。

1 个答案:

答案 0 :(得分:0)

经过更多搜索后找到答案

@Query("SELECT * FROM tbl_dataItem WHERE productName LIKE  '%'||:keyword||'%' ")
    Single<List<DataItem>> search(String keyword);