我有以下内容:
Engine HorsePower Type
Model 1 500 V10
Model 2 230 A7
Model 3 330 IVTEC
Model 4 400 V8
Model 5 300 VX500
我要过滤上面数据框中的行,其中“类型”的列以字母“ V”开头
因此,我会得到:
Engine HorsePower Type
Model 1 500 V10
Model 4 400 V8
Model 5 300 VX500
上面每一列的数据类型都是“ factor”类型。我尝试过类似的事情:
new_df <- new_df$AVC == "V"
但是结果输出只是FALSE和TRUE。希望对此有所帮助。
答案 0 :(得分:0)
new_df[grepl("^V", new_df$Type),]
这将为您提供new_df$Type
以"V"
开头的所有行。