Description Usage Arguments Details Value Author(s) References See Also Examples
Draws a scatter plot or a matrix of scatter plots
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | scatterplot(
data,
data.var,
z.var = NULL,
palette = NULL,
labels = NULL,
repel_labels = FALSE,
text_label = TRUE,
subset = NULL,
col.subset = "gray50",
zoom = NULL,
title = NULL,
legend = TRUE,
upper = list(continuous = "cor", combo = "box_no_facet", discrete = "facetbar", na =
"na"),
lower = list(continuous = "points", combo = "facethist", discrete = "facetbar", na =
"na"),
diag = list(continuous = "densityDiag", discrete = "barDiag", na = "naDiag")
)
|
data |
an object of class |
data.var |
character or numeric vector, name or column number of variables (in |
z.var |
character or number, name or column number of variable (in |
palette |
color palette (active when plotting a single scatter plot; see Value). |
labels |
character vector, labels for points (active when plotting a single scatter plot, see Value). |
repel_labels |
logical; if |
text_label |
logical; if |
subset |
logical or numeric vector, to select a subset of points to be highlighted (active when plotting a single scatter plot; see Value). |
col.subset |
character, color for the labels and rectangles of highlighted points (active when plotting a single scatter plot; see Value). |
zoom |
numeric vector with 4 elements; |
title |
character, plot title. |
legend |
logical, if |
upper |
list, may contain the variables |
lower |
list, may contain the variables |
diag |
list, may contain the variables |
If length(data.var)=2
, the variable specified in z.var
can be numeric or factor; if length(data.var)>2
, the variable specified in z.var
must be a factor.
A ggplot2
object with a single scatter plot if length(data.var)=2
or a matrix of scatter plots if length(data.var)>2
.
Marco Sandri, Paola Zuccolotto, Marica Manisera (basketball.analyzer.help@gmail.com)
P. Zuccolotto and M. Manisera (2020) Basketball Data Science: With Applications in R. CRC Press.
1 2 3 4 5 6 7 8 9 | # Single scatter plot
Pbox.sel <- subset(Pbox, MIN>= 500)
X <- data.frame(AST=Pbox.sel$AST/Pbox.sel$MIN,TOV=Pbox.sel$TOV/Pbox.sel$MIN)
X$PTSpm <- Pbox.sel$PTS/Pbox.sel$MIN
mypal <- colorRampPalette(c("blue","yellow","red"))
scatterplot(X, data.var=c("AST","TOV"), z.var="PTSpm", labels=1:nrow(X), palette=mypal)
# Matrix of scatter plots
data <- Pbox[1:50, c("PTS","P3M","P2M","OREB","Team")]
scatterplot(data, data.var=1:4, z.var="Team")
|
Loading required package: ggplot2
Registered S3 method overwritten by 'GGally':
method from
+.gg ggplot2
If you want to reproduce the figures contained in the book of
Zuccolotto and Manisera (2020) and
if the version of your R machine is >= 3.6.0, you need to type
RNGkind(sample.kind = "Rounding")
at the beginning of your working session
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.