# NOT RUN {
# Generate a random 10x10 matrix and plot it using default values
set.seed(1234) # for reproducibility
mat <- matrix(rnorm(120), nrow = 20) # standard normal
PAM.hm(mat, cluster.number = 3)
## Plot with more than one cluster number
PAM.hm(mat, cluster.number = 2:4) # integer vector
PAM.hm(mat, cluster.number = c("2", "4-5")) # character vector
# Using the 'trim' argument
## Introduce outlier to the matrix and plot w/o trimming or winsorization
mat[1] <- mat[1] * 10
PAM.hm(mat, cluster.number = 3, trim = NULL, winsorize = FALSE)
## calculate a trim value by getting the largest possible absolute integer and
## plot again
tr <- min(abs(ceiling(c(min(mat, na.rm = TRUE), max(mat, na.rm = TRUE)))),
na.rm = TRUE)
PAM.hm(mat, cluster.number = 3, trim = tr, winsorize = FALSE)
## Note that the outlier is still visible but since it is less extreme
## it does not distort the colour scheme.
# An example reading data from an Excel file
# The function readxl::read_excel is used internally to read Excel files.
# The example uses their example data.
readxl_datasets <- readxl::readxl_example("datasets.xlsx")
PAM.hm(readxl_datasets, cluster.number = 4, symbolcol = 5)
# }
Run the code above in your browser using DataLab