-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Style code used in examples #4098
Conversation
The sf tests don't fail in the continuous integration runs. If tests fail for you locally you may have to update sf. |
Thanks for the contribution!
You probably are using the older version of scales. These Rd files are now |
@rjake Could you update scales package and regenerate the docs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I added some comment on where another answer might be available, but they are just a matter of preferences so leave the questions for now.
#' base <- | ||
#' ggplot() + | ||
#' xlim(-5, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question is a like break after <-
should be added or not, but I think either is fine.
#' | ||
#' # Add a text annotation | ||
#' p + | ||
#' geom_text() + | ||
#' annotate("text", label = "plot mpg vs. wt", x = 2, y = 15, size = 8, colour = "red") | ||
#' annotate( | ||
#' "text", label = "plot mpg vs. wt", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "text",
can be placed in the same line of annotate(
, but this is also fine.
Short unnamed arguments can also go on the same line as the function name, even if the whole function call spans multiple lines.
https://style.tidyverse.org/syntax.html#long-lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that Ctrl + Enter sometimes errors out at the bottom if the pattern is mismatched about code touching the parentheses or not
# fine
annotate("text",
label = "plot mpg vs. wt")
# fine
annotate(
"text",
label = "plot mpg vs. wt"
)
# not fine
annotate("text",
label = "plot mpg vs. wt"
)
Here's an example
library(tidyverse)
mpg %>%
mutate(
x1 = "ok here") %>%
mutate(
x2 = "not ok") # use Ctrl + Enter in this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, thanks for the information. I hope this will be fixed on RStudio...
Thanks! |
Fixes #4092
This is my first PR for
ggplot2
. This will use the tidyverse style in the example code. I tried to check all docs. It was mentioned that a bigger audit might be done viastyler
at a later date and so I only picked a few types of coding style to change. If the code looked like thisI left it be.
I only moved to new lines when there was more than one pipe present
when the arguments weren't indented under the parentheses, or when the line had two functions
ggplot() + geom...
There were some updates that
roxygen2
(dev version) made that I committed at the endI also had 2 failed tests that seemed unrelated to my code changes
![image](https://user-images.githubusercontent.com/14003618/85894055-01cd6d80-b7c2-11ea-85e7-02e0ba8a495e.png)