TeachingDemos (version 2.12)

faces2: Chernoff Faces

Description

Plot Chernoff Faces of the dataset, rows represent subjects/observations, columns represent variables.

Usage

faces2(mat, which = 1:ncol(mat), labels = rownames(mat),
  nrows = ceiling(nrow(mat)/ncols), ncols = ceiling(sqrt(nrow(mat))),
  byrow = TRUE, scale = c("columns", "all", "center", "none"),
  fill = c(0.5, 0.5, 1, 0.5, 0.5, 0.3, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
           0.5, 0.5, 0.5, 0.5, 1, 0.5), ...)

Value

This function is run for its side effect of plotting and does not return anything.

Arguments

mat

Matrix containing the data to plot.

which

Which columns correspond to which features (see details).

labels

Labels for the individual faces

nrows

Number of rows in the graphical layout

ncols

Number of columns in the graphical layout

byrow

Logical, should the faces be drawn rowwise or columnwise.

scale

Character, how should the data be scaled.

fill

What value to use for features not assocaiated with a column of data.

...

Additional arguments passed on to plotting functions.

Author

Original code by ; current implementation by Greg Snow 538280@gmail.com

Details

The features are: 1 Width of center 2 Top vs. Bottom width (height of split) 3 Height of Face 4 Width of top half of face 5 Width of bottom half of face 6 Length of Nose 7 Height of Mouth 8 Curvature of Mouth (abs < 9) 9 Width of Mouth 10 Height of Eyes 11 Distance between Eyes (.5-.9) 12 Angle of Eyes/Eyebrows 13 Circle/Ellipse of Eyes 14 Size of Eyes 15 Position Left/Right of Eyeballs/Eyebrows 16 Height of Eyebrows 17 Angle of Eyebrows 18 Width of Eyebrows

The face plotting routine needs the data values to be between 0 and 1 (inclusive). The scale option controls how scaling will be done on mat: "columns" scales each column to range from 0 to 1, "all" scales the entire dataset to vary from 0 to 1, "center" scales each column so that the mean of the column becomes 0.5 and all other values are between 0 and 1, and "none" does no scaling assuming that the data has already been scaled.

References

Chernoff, H. (1973): The use of faces to represent statistiscal assoziation, JASA, 68, pp 361--368.

See Also

faces

Examples

Run this code
  faces2(matrix( runif(18*10), nrow=10), main='Random Faces')

if(interactive()){
  tke2 <- rep( list(list('slider',from=0,to=1,init=0.5,resolution=0.1)), 18)
  names(tke2) <- c('CenterWidth','TopBottomWidth','FaceHeight','TopWidth',
	'BottomWidth','NoseLength','MouthHeight','MouthCurve','MouthWidth',
	'EyesHeight','EyesBetween','EyeAngle','EyeShape','EyeSize','EyeballPos',
	'EyebrowHeight','EyebrowAngle','EyebrowWidth')
  tkfun2 <- function(...){
	tmpmat <- rbind(Min=0,Adjust=unlist(list(...)),Max=1)
	faces2(tmpmat, scale='none')
  }

  tkexamp( tkfun2, list(tke2), plotloc='left', hscale=2, vscale=2 )
}

Run the code above in your browser using DataCamp Workspace