Find string in data.frame

后端 未结 4 1708
清歌不尽
清歌不尽 2021-01-05 01:12

How do I search for a string in a data.frame? As a minimal example, how do I find the locations (columns and rows) of \'horse\' in this data.frame?



        
4条回答
  •  灰色年华
    2021-01-05 01:52

    What about:

    which(df == "horse", arr.ind = TRUE)
    #      row col
    # [1,]   2   1
    # [2,]   3   1
    # [3,]   5   2
    # [4,]   4   3
    

提交回复
热议问题