Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • The real answer is the difference between simplifying and preserving. [ will simplify and [[ will preserve. My answer below produces the exact same result as this answer, which can be tested using set.seed and identical. The reason the poster's code didn't work was because he asked for simplification with [ instead of preserve with [[. Commented Mar 21, 2018 at 13:37
  • If an alternative soluton produces “the exact same result” then it is not “the real answer” it is an alternative answer. Commented Mar 21, 2018 at 14:08
  • By real answer I mean that the problem was caused by simplification vs preservation. Understanding the difference between preservation and simplification in lists is what allows a person to understand why the original code did not produce the right answer. The "real" answer would be to explain simplification and preservation in lists. Commented Mar 21, 2018 at 15:09