I have a piece of code where I have to filter a dataframe based on a value. I read a dataset with 100 rows of data.
baseData = fread(file = "./Data/ABC.csv", data.table = FALSE, stringsAsFactors = FALSE, showProgress = FALSE, encoding = "UTF-8")
After I filter,
baseData = baseData %>% filter(., ab == 10)
Now I want to check whether the data has been filtered correctly. So I have written a condition,
ifelse((baseData$ab == 10),
"ab has been filtered correctly",
"ERROR")
but I have received the output like this,
[1] "ab has been filtered correctly" "ab has been filtered correctly" "ab has been filtered correctly"
[4] "ab has been filtered correctly" "ab has been filtered correctly" "ab has been filtered correctly"
[7] "ab has been filtered correctly" "ab has been filtered correctly" "ab has been filtered correctly"
[10] "ab has been filtered correctly" "ab has been filtered correctly" "ab has been filtered correctly"
.
.
.
I need a output like this,
"ab has been filtered correctly"
If possible along with the count of how many errors?
Aucun commentaire:
Enregistrer un commentaire