Если вы хотите отфильтровать все исправления, вы должны удалить все записи со значением Quantity < 0
:
df <- data.frame(InvoiceNo=c("C551685","551697"),
StockCode=c("POST","POST"),
Description=c("POSTAGE","POSTAGE"),
Quantity=c(-1,1),
InvoiceDate=c("5/3/2011 12:51","5/3/2011 13:46"),
UnitPrice=c(8142.75,8142.75),
CustomerID=c(16029,16029),
Country=c("United Kingdom", "United Kingdom"),
stringsAsFactors=F)
df
# InvoiceNo StockCode Description Quantity InvoiceDate UnitPrice CustomerID Country
#1 C551685 POST POSTAGE -1 5/3/2011 12:51 8142.75 16029 United Kingdom
#2 551697 POST POSTAGE 1 5/3/2011 13:46 8142.75 16029 United Kingdom
#Filter out all corrections:
df[df$Quantity < 0, ]
# InvoiceNo StockCode Description Quantity InvoiceDate UnitPrice CustomerID Country
#1 C551685 POST POSTAGE -1 5/3/2011 12:51 8142.75 16029 United Kingdom
Если вы хотите удалить все транзакции, то:
#Filter out all transactions:
df[df$Quantity > 0, ]
# InvoiceNo StockCode Description Quantity InvoiceDate UnitPrice CustomerID Country
#2 551697 POST POSTAGE 1 5/3/2011 13:46 8142.75 16029 United Kingdom