I'm working in R with a large data set of passwords (10 million) and would like to assign a value to each password based on certain criteria. If it's all lowercase or all uppercase, 26, all numeric, 10, mixed case, 52, all punctuation, 31 etc, etc. Part of this is of course identifying which group each password belongs to.
I know that I can use nested if-statments and regex to achieve this, but it would become incredibly messy. I am relatively new to programming, and so I can't quite figure out a better way to achieve this.
One thought is that I could use a for loop to run through all of the passwords, and I will likely end up doing this, but that doesn't get rid of the need for the nested if-statements within the loop.
How my code would look if I stuck with regex/ifs:
ifelse((grepl("[0-9]", most_repeated_pass)),10,
ifelse((grepl("[a-z]", most_repeated_pass)),26,
ifelse((grepl("[A-Z]", most_repeated_pass)),26, 0)))
So on and so forth. The above would be inside a for loop.
There must be a better way. Even just pointing me in the right direction is much appreciated.
Aucun commentaire:
Enregistrer un commentaire