如何编写代码以查找样式下带有"Alternative“一词的行。但不仅仅是“替代”本身,而是“替代”与其他条件相结合。这里的数据被称为金属
style
id brand_id brand_name origin formed split fans style
5 1038 Keldian Norway 2005 2005 54 Adult
6 2022 Dawn Of Ashes USA 2001 2001 17 Aggrotech
7 43 Sepultura Brazil 1984 2003 1185 Alternative
8 3388 Louna Russia 2007 2008 5 Alternative rock
9 785 Stam1na Finland 1992 1996 78 Alternative thrash很容易找到样式下的列,只有下面这样的“替代”:
metals[metals$style == "Alternative",]但我想找出样式下有“另类”字样的行,不管它是否还有一个词像石头一样,这意味着我要用上面贴出的样本打印3行。
发布于 2022-05-11 13:18:24
使用grepl匹配模式:
metals[grepl("(?i)Alternative", metals$style),]请注意,(?i)标志用于使匹配不区分大小写,这样就可以找到诸如"alternative“甚至"alterNAtive”之类的值。
https://stackoverflow.com/questions/72200840
复制相似问题