# With fuzzy variables
data(bsetal97)
w <- prep.fuzzy(bsetal97$biol, bsetal97$biol.blo)
w[1:6, 1:10]
ktab1 <- ktab.list.df(list(w))
dis <- dist.ktab(ktab1, type = "F")
as.matrix(dis)[1:5, 1:5]
## Not run:
# # With ratio-scale and multichoice variables
# data(ecomor)
#
# wM <- log(ecomor$morpho + 1) # Quantitative variables
# wD <- ecomor$diet
# # wD is a data frame containing a multichoice nominal variable
# # (diet habit), with 8 modalities (Granivorous, etc)
# # We must prepare it by prep.binary
# head(wD)
# wD <- prep.binary(wD, col.blocks = 8, label = "diet")
# wF <- ecomor$forsub
# # wF is also a data frame containing a multichoice nominal variable
# # (foraging substrat), with 6 modalities (Foliage, etc)
# # We must prepare it by prep.binary
# head(wF)
# wF <- prep.binary(wF, col.blocks = 6, label = "foraging")
# # Another possibility is to combine the two last data frames wD and wF as
# # they contain the same type of variables
# wB <- cbind.data.frame(ecomor$diet, ecomor$forsub)
# head(wB)
# wB <- prep.binary(wB, col.blocks = c(8, 6), label = c("diet", "foraging"))
# # The results given by the two alternatives are identical
# ktab2 <- ktab.list.df(list(wM, wD, wF))
# disecomor <- dist.ktab(ktab2, type= c("Q", "B", "B"))
# as.matrix(disecomor)[1:5, 1:5]
# contrib2 <- kdist.cor(ktab2, type= c("Q", "B", "B"))
# contrib2
#
# ktab3 <- ktab.list.df(list(wM, wB))
# disecomor2 <- dist.ktab(ktab3, type= c("Q", "B"))
# as.matrix(disecomor2)[1:5, 1:5]
# contrib3 <- kdist.cor(ktab3, type= c("Q", "B"))
# contrib3
#
# # With a range of variables
# data(woangers)
#
# traits <- woangers$traits
# # Nominal variables 'li', 'pr', 'lp' and 'le'
# # (see table 1 in the main text for the codes of the variables)
# tabN <- traits[,c(1:2, 7, 8)]
# # Circular variable 'fo'
# tabC <- traits[3]
# tabCp <- prep.circular(tabC, 1, 12)
# # The levels of the variable lie between 1 (January) and 12 (December).
# # Ordinal variables 'he', 'ae' and 'un'
# tabO <- traits[, 4:6]
# # Fuzzy variables 'mp', 'pe' and 'di'
# tabF <- traits[, 9:19]
# tabFp <- prep.fuzzy(tabF, c(3, 3, 5), labels = c("mp", "pe", "di"))
# # 'mp' has 3 levels, 'pe' has 3 levels and 'di' has 5 levels.
# # Quantitative variables 'lo' and 'lf'
# tabQ <- traits[, 20:21]
# ktab1 <- ktab.list.df(list(tabN, tabCp, tabO, tabFp, tabQ))
# distrait <- dist.ktab(ktab1, c("N", "C", "O", "F", "Q"))
# is.euclid(distrait)
# contrib <- kdist.cor(ktab1, type = c("N", "C", "O", "F", "Q"))
# contrib
# dotchart(sort(contrib$glocor), labels = rownames(contrib$glocor)[order(contrib$glocor[, 1])])
# ## End(Not run)
Run the code above in your browser using DataLab