PCAOS package allows to perform Single and MultiBlock exploratory analysis of datasets composed of variables with different natures.
if (!require("devtools")) install.packages("devtools")
library(devtools)
install_github("martinparies/PCA.OS")
library(PCA.OS)
help(PCA.OS)
data("antibiotic")
help(antibiotic)
#Manually
level.scale <- rep(NA,ncol(antibiotic)) #Setting level.scale argument
level.scale[c(3,4)] <- "num"
level.scale[c(6:14)] <- "nom"
level.scale[c(1,15)] <- "ord"
#Or using nature.variables()
level.scale <- rep(NA,ncol(antibiotic))
res.nature <- nature.variables(antibiotic)
level.scale [res.nature$p.numeric] <- "num"
level.scale [res.nature$p.quali] <- "nom"
#Warning; the ordinal nature of variables can not be detected automaticaly.
level.scale[c(1,15)] <- "ord"
help(choice.component)
res.choice <- choice.component(antibiotic,level.scale)
res.choice
help(PCAOS)
res.PCAOS <- PCAOS(
data = antibiotic,
level.scale = level.scale,
nb.comp = 2)
help(plot.PCAOS)
#Individuals
plot.PCAOS(
x = res.PCAOS,
choice = "ind",
coloring.indiv = antibiotic$Atb.conso,
size.legend = 12,
size.label = 4
)
# Variables
plot.PCAOS(x = res.PCAOS,choice = "all.var")
data('antibiotic')
antb.uses <- antibiotic[,c('Atb.conso','Atb.Sys')]
health <- antibiotic[,c('Age','Loss')]
vet.practices <- antibiotic[,c(6:15)]
antibiotic.MB <- data.frame(antb.uses,health,vet.practices)
blocks.name = c("antibiotic.uses","Health.of.turkeys","Veterinary.practices")
blocks <- c(2,2,10)
level.scale.MB <- rep(NA,ncol(antibiotic.MB))
res.nature <- nature.variables(antibiotic.MB)
level.scale.MB [res.nature$p.numeric] <- "num"
level.scale.MB [res.nature$p.quali] <- "nom"
#Warning; the ordinal nature of variables can not be detected automaticaly.
level.scale.MB[c(1,14)] <- "ord"
help(choice.component.MB)
res.choice.MB <- choice.component.MB(antibiotic.MB,level.scale.MB, blocks , blocks.name, block.scaling = 'inertia')
res.choice.MB
res.MBPCAOS <- MBPCAOS(data = antibiotic.MB,
level.scale = level.scale.MB,
blocks = blocks,
blocks.name = blocks.name,
nb.comp = 3)
plot.MBPCAOS(res.MBPCAOS,choice = 'blocks')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.