dev/triads.R

# Triads functions -----






# Triad taste example ----
data(taste)

d                    <- taste[which(taste$Isup == 'Active'), ]
a0                   <- d %>% select(TV, Film, Art, Eat)

d1                   <- d[which(d$Gender == 'Women'), ]
a1                   <- d1 %>% select(TV, Film, Art, Eat)

d2                   <- d[which(d$Gender != 'Women'), ]
a2                   <- d2 %>% select(TV, Film, Art, Eat)

d3                    <- taste
a3                   <- d3 %>% select(TV, Film, Art, Eat)




l.mca                <- list("Original" = soc.mca(a0, identifier = d$ID),
                             "No Passive" = soc.mca(a3, identifier = d3$ID),
                             "Women" = soc.mca(a1, identifier = d1$ID),
                             "Men" = soc.mca(a2, identifier = d2$ID)
                            )

l.triads             <- list()

l.triads$A           <- d %>% transmute(id = as.character(ID), 
                               "TV: Comedy" = TV == "Tv-Comedy",
                               "Eat: IndianRest" = Eat == "IndianRest",
                               "Art: StillLife" = Art == "StillLife")

l.triads$B           <- d %>% transmute(id = as.character(ID), 
                                        "Art: Impressionism" = Art == "Impressionism",
                                        "Eat: FrenchRest" = Eat == "FrenchRest",
                                        "Art: RenaissanceArt" = Art == "RenaissanceArt")


l.triads$C           <- d %>% transmute(id = as.character(ID), 
                                        "Film: Romance" = Film == "Romance",
                                        "TV: Tv-Soap" = TV == "Tv-Soap",
                                        "Art: Portrait" = Art == "Portrait")

l.triads$D           <- d %>% transmute(id = as.character(ID), 
                                        "Eat: SteakHouse"   = Eat == "SteakHouse",
                                        "Art: Landscape"    = Art == "Landscape",
                                        "Film: Documentary" = Film == "Documentary")



l.mca.triads         <- mca.triads(l.mca, l.triads, dim = c(1, 2), fix.mca = 1)



library(RColorBrewer)
mca.triad.array(l.mca.triads)
Rsoc/soc.ca documentation built on March 7, 2024, 8:59 p.m.