我有以下格式的数据框
Question Year
filter with question? 2010
keep this row 2009
keep this row too 2008
remove this one? 2007
预期结果
Question Year
keep this row 2009
keep this row too 2008
获取不包括列的数据框子集问题包含问号'?'。
答案 0 :(得分:1)
我们可以使用grep
过滤掉“问题”列中的?
元素
df1[!grepl('\\?', df1$Question),]
# Question Year
#2 keep this row 2009
#3 keep this row too 2008