Handling permutation errors in R?

I wanted to shuffle characters in all strings by all means, I used the command:

string <- "hello"
all_permutations <- gtools::permutations(nchar(string), nchar(string), string)
strings <- c("hello", "world", "bing")
for (string in strings) {
all_permutations <- gtools::permutations(nchar(string), nchar(string), string)
print(all_permutations)
}

But I got an error:

all_permutations <- gtools::permutations(nchar(string), nchar(string), string)
Error in gtools::permutations(nchar(string), nchar(string), string) :
v is either non-atomic or too short

Currently I don't know how to handle it, thank you for your help.

gtools::permutations will permute members of a set that you give it; but you are giving it sets of size 1; each time. gtools::permutations will not take your string and chop it up into letters. so if you want a string chopped up into letters, then you will have to add the code for that.