根据列中的字符串值筛选dataframe中的行
我有以下资料:根据列中的字符串值筛选dataframe中的行,r,R,我有以下资料: Engine HorsePower Type Model 1 500 V10 Model 2 230 A7 Model 3 330 IVTEC Model 4 400 V8 Model 5 300 VX500 我想过滤上面数据框中的行,其中“Type”列以字母“V”开头 因此,我会得到: Engine
Engine HorsePower Type
Model 1 500 V10
Model 2 230 A7
Model 3 330 IVTEC
Model 4 400 V8
Model 5 300 VX500
我想过滤上面数据框中的行,其中“Type”列以字母“V”开头
因此,我会得到:
Engine HorsePower Type
Model 1 500 V10
Model 4 400 V8
Model 5 300 VX500
上述各列的数据类型均为“因子”类型。我尝试了类似于:
new_df <- new_df$AVC == "V"
new\u df
这将为您提供所有new_df$Type
以“V”
开头的行
new_df[grepl("^V", new_df$Type),]