我有一个名为shops
的数据框,其中的列loyalty_customer
包含0或1,具体取决于它们是否被归类为忠诚度客户:
customer loyalty_customer
bob 1
karen 1
jim 0
我想保留所有loyaty_customer,并在新的数据框中摆脱普通客户。我已经尝试过了:
mask <- shops$loyalty_customer == 1
cust <-shops[mask]
但是我遇到以下错误:
Error in [.data.frame(shops, mask) :
undefined columns selected
我不明白这里发生了什么,所以有人可以解释一下。
谢谢。