You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Tomaž. I know the typical idiom for scrambling letters in R involves strsplit.
Here's another approach: use charToRaw and rawToChar instead.
# Helper function. Can also be placed inside of WordScrambler() instead or be an# anonymous function in the `tapply` step.fun<-function(x) rawToChar(sample(x))
WordScrambler<-function(text) {
w<- charToRaw(text)
words<- cumsum(w=="20")
tolower(paste(tapply(w[w!="20"], words[w!="20"], fun), collapse=""))
}
The text was updated successfully, but these errors were encountered:
Hi Tomaž. I know the typical idiom for scrambling letters in R involves
strsplit
.Here's another approach: use
charToRaw
andrawToChar
instead.The text was updated successfully, but these errors were encountered: