Skip to content

Commit

Permalink
document the failure of yihui/formatR#54
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Dec 7, 2017
1 parent 811bb42 commit 16fe64d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions content/pkg-formatR.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ We can also use the right arrow `->` for assignment, e.g. `1:10 -> x`. I believe

I recommend you to use `<-` or `=` consistently. What is more important is consistency. I always use `=` because it causes me no confusion (I do not believe it is ever possible for people to interpret `fun(a = 1)` as assigning `1` to a variable `a` instead of passing an argument value) and `<-` is more dangerous because it works everywhere (you might have unconsciously created a new variable `a` in `fun(a <- 1)`; see [an example here](https://stat.ethz.ch/pipermail/r-devel/2011-December/062786.html)). The only disadvantage is that most R people use `<-` so it may be difficult to collaborate with other people.

## The pipe operator `%>%`

Although `tidy_source()` won't ruin your code that contains the pipes, you won't be happy with it: your line breaks after the pipes won't be preserved. See [#54](https://github.com/yihui/formatR/issues/54).

# 7. How does `tidy_source()` actually work?

In a nutshell, `tidy_source(text = code)` is basically `deparse(parse(text = code))`, but actually it is more complicated only because of one thing: `deparse()` drops comments, e.g.,
Expand Down

0 comments on commit 16fe64d

Please sign in to comment.