Let’s get to the bottom of this important issue

How do you get a shruggie in R Markdown? What you type is not what you get.

# of \ What you type What you see Comments
1 ¯\_(ツ)_/¯ ¯_(ツ)_/¯
2 ¯\\_(ツ)_/¯ ¯\(ツ)
3 ¯\\\_(ツ)_/¯ ¯\_(ツ)_/¯ WINNER!*
4 ¯\\\\_(ツ)_/¯ ¯\\(ツ)

*UPDATE: Ok right it’s not this simple. You also need to escape the second underscore. Read on.

Thanks, Noam

Reviewer 3 (Noam Ross) has some grave concerns about the second underscore. Specifically, it too needs to be escaped if you don’t want to get unplanned italics after your shruggie. Here is the extended study.

# of \ 2nd \_? What you type What you see Comments
1 no ¯\_(ツ)_/¯ shruggie! ¯\_(ツ)_/¯ ¯_(ツ)/¯ shruggie! ¯_(ツ)
2 no ¯\\_(ツ)_/¯ shruggie! ¯\\_(ツ)_/¯ ¯\(ツ)/¯ shruggie! ¯\(ツ)
3 no ¯\\\_(ツ)_/¯ shruggie! ¯\\\_(ツ)_/¯ ¯\_(ツ)/¯ shruggie! ¯\_(ツ)
4 no ¯\\\\_(ツ)_/¯ shruggie! ¯\\\\_(ツ)_/¯ ¯\\(ツ)/¯ shruggie! ¯\\(ツ)
1 yes ¯\_(ツ)\_/¯ shruggie! ¯\_(ツ)\_/¯ ¯_(ツ)_/¯ shruggie! ¯_(ツ)_/¯
2 yes ¯\\_(ツ)\_/¯ shruggie! ¯\\_(ツ)\_/¯ ¯\(ツ)_/¯ shruggie! ¯\(ツ)_/¯
3 yes ¯\\\_(ツ)\_/¯ shruggie! ¯\\\_(ツ)\_/¯ ¯\_(ツ)_/¯ shruggie! ¯\_(ツ)_/¯ WINNER!
4 yes ¯\\\\_(ツ)\_/¯ shruggie! ¯\\\\_(ツ)\_/¯ ¯\\(ツ)_/¯ shruggie! ¯\\(ツ)_/¯

Of course this all makes sense when you remember even your prose is being processed as Markdown. All the usual escaping applies.

The obligatory xkcd.

In conclusion

And if you want R to print a shruggie in a string, you’ll need to escape it differently, because now the underscore has no special meaning, only the backslash does.

cat("¯\\_(ツ)_/¯ shruggie! ¯\\_(ツ)_/¯")
#> ¯\_(ツ)_/¯ shruggie! ¯\_(ツ)_/¯

But wait there’s more

This drifts more into encoding now, but here’s a nice site for getting under the hood of special characters. Let’s study the characters used in shruggie:

http://apps.timwhitlock.info/unicode/inspect?s=¯%5C_%28ツ%29_%2F¯

How did I get to thinking about this? Well, believe it or not shruggie is giving me trouble in certain contexts. Like as an anchor in floating tables of contents. Shocking, I know! So maybe shruggie should be used in moderation ¯\_(ツ)_/¯.