ALSO
Other users have found confusing results, too:
Oh wow! Base R's new pipe, |> behaves differently: sample(x = c(letters, LETTERS), size = sample.int(100, 1), replace = T) |> replicate(n = 20, expr = _, simplify = "array"). At first, I agree with your results but base R's pipe now confuses me!
Hi! This is more of a question than a bug or issue.
So I asked it on StackOverflow. But I ask it here in order to be found more easily by other users who encounter the same question.
The question
I want to generate a character vector with 20 elements, each has a random string.
So I generate a random string with the following code:
and I generate the vector with this:
(I am basically putting the first code chunk in
replicate
as an argument.) and the output is the following (which is exactly what I want):But here is the problem. When I try to pipe the first code chuck into
replicate
usingmagrittr
's pipe (%>%
), I get an output with similar strings!This is how I do it:
also, I tried to wrap them into parentheses:
But, in both cases, this is the undesirable output:
What do you think the problem is here?
ALSO Other users have found confusing results, too: