-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Style code used in examples #4098
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
Changes from all commits
03fcd70
a27896a
dd1e7de
f0401ad
14ed62a
b165897
77c778f
848fed1
e0588e0
2ab469d
fec13e0
717860b
dcc35c9
da5b96d
76e5458
8cc52a5
2bbe3d8
4ccf8f1
5c463a3
919fa09
0d7b261
c6d7250
5b6aa19
6d6ec2a
506b9cc
de849dc
a9ef9f3
16c5692
39d5d59
226e07f
0251d19
bf491cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,12 +64,19 @@ | |
#' p + geom_text(size = 10) | ||
#' | ||
#' # Set aesthetics to fixed value | ||
#' p + geom_point() + geom_text(hjust = 0, nudge_x = 0.05) | ||
#' p + geom_point() + geom_text(vjust = 0, nudge_y = 0.5) | ||
#' p + geom_point() + geom_text(angle = 45) | ||
#' p + | ||
#' geom_point() + | ||
#' geom_text(hjust = 0, nudge_x = 0.05) | ||
#' p + | ||
#' geom_point() + | ||
#' geom_text(vjust = 0, nudge_y = 0.5) | ||
#' p + | ||
#' geom_point() + | ||
#' geom_text(angle = 45) | ||
#' \dontrun{ | ||
#' # Doesn't work on all systems | ||
#' p + geom_text(family = "Times New Roman") | ||
#' p + | ||
#' geom_text(family = "Times New Roman") | ||
#' } | ||
#' | ||
#' # Add aesthetic mappings | ||
|
@@ -80,18 +87,26 @@ | |
#' | ||
#' p + geom_text(aes(size = wt)) | ||
#' # Scale height of text, rather than sqrt(height) | ||
#' p + geom_text(aes(size = wt)) + scale_radius(range = c(3,6)) | ||
#' p + | ||
#' geom_text(aes(size = wt)) + | ||
#' scale_radius(range = c(3,6)) | ||
#' | ||
#' # You can display expressions by setting parse = TRUE. The | ||
#' # details of the display are described in ?plotmath, but note that | ||
#' # geom_text uses strings, not expressions. | ||
#' p + geom_text(aes(label = paste(wt, "^(", cyl, ")", sep = "")), | ||
#' parse = TRUE) | ||
#' p + | ||
#' geom_text( | ||
#' aes(label = paste(wt, "^(", cyl, ")", sep = "")), | ||
#' parse = TRUE | ||
#' ) | ||
#' | ||
#' # 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 commentThe reason will be displayed to describe this comment to others. Learn more. This
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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... |
||
#' x = 2, y = 15, size = 8, colour = "red" | ||
#' ) | ||
#' | ||
#' \donttest{ | ||
#' # Aligning labels and bars -------------------------------------------------- | ||
|
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.c.f. https://style.tidyverse.org/pipes.html#assignment-2