Question: - **6d.**(0.3 point) Define a function `sentence.scrambler()` that operates similarly to to `sentence.flipper()`, but which randomly scrambles the order of characters in each word, instead

- **6d.**(0.3 point) Define a function `sentence.scrambler()` that operates similarly to to `sentence.flipper()`, but which randomly scrambles the order of characters in each word, instead of deterministically reversing them. The function `sentence.scrambler()` should be vectorized, just like the current version of `sentence.flipper()`. Hint: you can use `browser()` at any point if you run into bugs in your development, or simply to see how your function is handling certain test inputs. Also, the implementation of `sentence.scrambler()` should be pretty similar to `sentence.flipper()`; really, you just need to replace `word.flipper()` by a suitable function. Once done, run `sentence.scrambler()` on the test string below to display the output.

```{r, error=TRUE}

# Define sentence.scrambler() here

sentence.scrambler = function(str) {

paste(lapply(strsplit(strsplit(str, ",")[[1]], ""),

function(x) paste(rev(x), collapse = "")), collapse = " ")

}

sentence.scrambler(c("I have no theorems, well",

"I do have theorems, but none of them are named Fienberg's Theorem",

"Even if there were a Fienberg's Theorem, it probably wouldn't be important",

"What's important is the attitude, for what statistics is",

"and how it's recognized by other people outside of our field"))

```

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!