## Ordinating the USArrests dataset
ordination <- princomp(USArrests, cor = TRUE)
## Which dimensions to select?
(selected <- select.axes(ordination))
## The selected dimensions
selected$dimensions
## Visualising the results
plot(selected)
## Same but by grouping the data into three groups
states_groups <- list("Group1" = c("Mississippi","North Carolina",
"South Carolina", "Georgia", "Alabama",
"Alaska", "Tennessee", "Louisiana"),
"Group2" = c("Florida", "New Mexico", "Michigan",
"Indiana", "Virginia", "Wyoming", "Montana",
"Maine", "Idaho", "New Hampshire", "Iowa"),
"Group3" = c("Rhode Island", "New Jersey", "Hawaii",
"Massachusetts"))
(selected <- select.axes(ordination, group = states_groups))
## Note that the required number of axes is now 4 (instead of 3)
plot(selected)
## Loading some example dispRity data
data(demo_data)
## How many axes are required to explain 99% of the variance
## for each group in the Healy et al 2019 data?
(how_many <- select.axes(demo_data$healy, threshold = 0.99))
summary(how_many)
plot(how_many)
Run the code above in your browser using DataLab