<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: 2-D scatter plot with a partition in classes (levels of a...</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="https://rpkg.net/assets/examples.css" />
</head><body>

<table width="100%" summary="page for s.class"><tr><td>s.class</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>2-D scatter plot with a partition in classes (levels of a factor)</h2>

<h3>Description</h3>

<p>This function represents a two dimensional scatter plot grouping points to the same class.
Classes are represented by ellipses, stars and/or convex hulls.
</p>


<h3>Usage</h3>

<pre>
s.class(dfxy, fac, xax = 1, yax = 2, wt = rep(1, NROW(fac)), labels = levels(fac),
  ellipseSize = 1.5, starSize = 1, chullSize = NULL, col = NULL, facets = NULL,
  plot = TRUE, storeData = TRUE, add = FALSE, pos = -1, ...)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>dfxy</code></td>
<td>
<p>a data frame used to produce the plot</p>
</td></tr>
<tr valign="top"><td><code>fac</code></td>
<td>
<p>a factor (or a matrix of factors) splitting the rows of <code>dfxy</code></p>
</td></tr>
<tr valign="top"><td><code>xax</code></td>
<td>
<p>an integer (or a vector) indicating which column(s) of <code>dfxy</code> is(are) plotted on the x-axis</p>
</td></tr>
<tr valign="top"><td><code>yax</code></td>
<td>
<p>an integer (or a vector) indicating which column(s) of <code>dfxy</code> is(are) plotted on the y-axis</p>
</td></tr>
<tr valign="top"><td><code>wt</code></td>
<td>
<p>a vector of weights for <code>fac</code></p>
</td></tr>
<tr valign="top"><td><code>labels</code></td>
<td>
<p>a character vector containing the class' labels</p>
</td></tr>
<tr valign="top"><td><code>ellipseSize</code></td>
<td>
<p>a positive number for ellipse size</p>
</td></tr>
<tr valign="top"><td><code>starSize</code></td>
<td>
<p>a number between 0 and 1 for the size of the stars segments joining the stars' center 
(centroids) and the matching points</p>
</td></tr>
<tr valign="top"><td><code>chullSize</code></td>
<td>
<p><code>NULL</code> or a vector of numbers between 0 and 1 for the fraction of points included in the convex hull</p>
</td></tr>
<tr valign="top"><td><code>col</code></td>
<td>
<p>a color or a colors vector to color points, ellipses, labels, lines and polygons</p>
</td></tr>
<tr valign="top"><td><code>facets</code></td>
<td>
<p>a factor splitting the rows of <code>dfxy</code> so that subsets
of the data are represented on different sub-graphics</p>
</td></tr>
<tr valign="top"><td><code>plot</code></td>
<td>
<p>a logical indicating if the graphics is displayed</p>
</td></tr>
<tr valign="top"><td><code>storeData</code></td>
<td>
<p>a logical indicating if the data should be stored in
the returned object. If <code>FALSE</code>, only the names of the data
arguments are stored</p>
</td></tr>
<tr valign="top"><td><code>add</code></td>
<td>
<p>a logical. If <code>TRUE</code>, the graphic is superposed to the graphics
already plotted in the current device</p>
</td></tr>
<tr valign="top"><td><code>pos</code></td>
<td>
<p>an integer indicating the position of the
environment where the data are stored, relative to the environment
where the function is called. Useful only if <code>storeData</code> is
<code>FALSE</code></p>
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
<p>additional graphical parameters (see
<code>adegpar</code> and <code>trellis.par.get</code>)</p>
</td></tr>
</table>


<h3>Details</h3>

<p>Graphical parameters for ellipses, stars and convex hulls are available in <code>pellipses</code>, <code>plines</code> and <code>ppolygons</code> of <code>adegpar</code>.
</p>


<h3>Value</h3>

<p>An object of class <code>ADEg</code> (subclass <code>S2.class</code>) or <code>ADEgS</code> (if <code>add</code> is <code>TRUE</code> and/or 
if facets or multidimensional <code>fac</code> or vectors for <code>xax</code>/<code>yax</code> are used).<br />
The result is displayed if <code>plot</code> is <code>TRUE</code>.
</p>


<h3>Author(s)</h3>

<p>Alice Julien-Laferriere, Aurelie Siberchicot <a href="mailto:aurelie.siberchicot@univ-lyon1.fr">aurelie.siberchicot@univ-lyon1.fr</a> and Stephane Dray
</p>


<h3>See Also</h3>

<p><code>S2.class</code>
<code>ADEg.S2</code>
</p>


<h3>Examples</h3>

<pre>
xy &lt;- cbind.data.frame(x = runif(200, -1, 1), y = runif(200, -1, 1))
posi &lt;- factor(xy$x &gt; 0) : factor(xy$y &gt; 0)
coul &lt;- c("black", "red", "green", "blue")
s.class(xy, fac = posi, col = coul, psub.text = "example s.class", pellipses.col = coul)

s.class(xy, fac = posi, ppoints.cex = 1.5, ellipseSize = 0, starSize = 0,
  ppolygons = list(border = 4:1, col = 1:4, lty = 1:4, lwd = 2, alpha = 0.4),
  chullSize = c(1, 0.5))

s.class(xy, fac = posi, facets = posi, ppoints.cex = 1.5, ellipseSize = 0, starSize = 0,
  ppolygons = list(border = 4:1, col = 1:4, lty = 1:4, lwd = 2, alpha = 0.4),
  chullSize = c(1, 0.5))
  
## Not run:  
s.class(xy, fac = posi, col = coul, psub.text = "example s.class", pellipses.col = coul, 
  plabels.cex = 0, key = list(space = "left"))
   
data(banque, package = "ade4")
dudi1 &lt;- ade4::dudi.acm(banque, scannf = FALSE)
col &lt;- rainbow(length(levels(banque[, 20])))
g1 &lt;- s.label(dudi1$li, psub = list(text = "Factorial map from ACM", cex = 1.5, 
  position = "topleft"), plot = FALSE)
g2 &lt;- s.class(dudi1$li, banque[, 20], psub = list(text = names(banque)[20], cex = 1.5, 
  position = "bottomright"), ellipseSize = 0, starSize = 0.5, pgrid.text.cex = 0, plot = FALSE)
g3 &lt;- s.class(dudi1$li, banque[, 20], starSize = 0, ellipseSize = 2, pgrid.text.cex = 0, 
  plabels.cex = 1.5, plot = FALSE)
g4 &lt;- s.class(dudi1$li, banque[, 20], psub = list(text = names(banque)[20], 
  position = "topright"), pgrid.text.cex = 0, col = col, pellipses.lwd = 1.5, plot = FALSE)
G1 &lt;- ADEgS(c(g1, g2, g3, g4), layout = c(2, 2))
G2 &lt;- s.class(dudi1$li, banque, psub = list(position = "topleft"), pgrid.text.cex = 0, 
  starSize = 0, ppoints.cex = 0)

## End(Not run)
</pre>


</body></html>
