我正在尝试使用 R 进行一些密码分析,特别是如下所示的短列表(50 个密码)的开头和结尾的字符。
> dput(Final_DF$Pswd)
c("monkey", "iloveyou", "dragon", "jbI2pnK$xi", "password", "computer",
"!qessw", "tUNh&SSm6!", "sunshine", "wYrUeWV", "superman", "samsung",
"utoXGe6$", "master", "wjZC&OvXX", "0R1cNTm9sGir", "Fbuu2bs89?",
"pokemon", "secret", "x&W1TjO59", "buster", "purple", "shine",
"flower", "marina", "Tg%OQT$0", "SbDUV&nOX", "peanut", "angel",
"?1LOEc4Zfk", "computer", "spiderman", "nothing", "$M6LgmQgv$",
"orange", "knight", "american", "outback", "TfuRpt3PiZ", "air",
"surf", "lEi2a$$eyz", "date", "V$683rx$p", "newcastle", "estate",
"foxy", "ginger", "coffee", "legs")
我可以通过
绘制开头的字符#plot what characters are at the end on a graph
fact1 <- table(str_extract(Final_DF$Pswd, "[[:punct:]]$"))
fact2 <- table(str_extract(Final_DF$Pswd, "[[:digit:]]$"))
fact3 <- table(str_extract(Final_DF$Pswd, "[[:lower:]]$"))
fact4 <- table(str_extract(Final_DF$Pswd, "[[:upper:]]$"))
barplot(c(fact1, fact2, fact3, fact4))
但是,当我对开头的字符执行相同操作时,我似乎在 x 轴上丢失了一些字符
fact5 <- table(str_extract(Final_DF$Pswd, "^[[:punct:]]"))
fact6 <- table(str_extract(Final_DF$Pswd, "^[[:digit:]]"))
fact7 <- table(str_extract(Final_DF$Pswd, "^[[:lower:]]"))
fact8 <- table(str_extract(Final_DF$Pswd, "^[[:upper:]]"))
barplot(c(fact5, fact6, fact7, fact8))
有人知道发生了什么吗?