library(dplyr)
library(openxlsx)

wrong_emails_df <- dataset %>%
    filter( isEmailValidFromRegex == 0 ) %>%
    select( UserId, Email )

wrong_dates_df <- dataset %>%
    filter( isDateValidFromRegex == 0 ) %>%
    select( UserId, BannedDate )

df_named_lst <- list("Wrong emails" = wrong_emails_df, "Wrong dates" = wrong_dates_df)

write.xlsx(df_named_lst, file = r'{D:\<twoja-ścieżka>\Chapter07\R\wrong-data.xlsx}')

# Zachowaj tylko wiersze z prawidłowym adresem e-mail i datą blokady
df <- dataset %>%
    filter( isEmailValidFromRegex == 1 & isDateValidFromRegex == 1 )
