Removing rows with * prefixed string

前端 未结 5 1918
故里飘歌
故里飘歌 2021-01-27 06:22

I have a data frame which is as given below

85  P   74  P   70  P   35  P   38  P   54
49  P   35  P   30  P   50  P   30  P   30
104 P   69  P   50  P   70  P           


        
5条回答
  •  深忆病人
    2021-01-27 06:36

    You can use lapply and Reduce (and three other functions, grep, intersect, and [):

    dat[Reduce(intersect, lapply(dat, grep, pattern = "^[^*]")), ]
    #    V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11
    # 1  85  P 74  P 70  P 35  P 38   P  54
    # 2  49  P 35  P 30  P 50  P 30   P  30
    # 3 104  P 69  P 50  P 70  P 70   P  87
    # 6  76  P 86  P 69  P 84  P 66   P  79
    # 7 110  P 65  P 40  P 57  P 57   P  74
    

提交回复
热议问题