# NOT RUN {
# Example with G data of class "data.frame", corresponding to
# microsatellites of a diploid organism:
data(eco.test)
eco <- ecogen(XY = coordinates, P = phenotype, G = genotype,
E = environment, S = structure)
# Example with G data of class "data.frame", corresponding to a
# presence - absence molecular marker:
dat <- sample(c(0,1),100,rep = TRUE)
dat <- data.frame(matrix(dat,10,10))
eco <- ecogen(G = dat, type = "dominant")
# DINAMIC ASSIGNMENT WITH ACCESSORS AND "[["
eco <- ecogen(XY = coordinates, P = phenotype)
eco
ecoslot.G(eco, order.G = TRUE) <- genotype
# this is identical to
eco[["G", order.G=TRUE]] <- genotype
ecoslot.E(eco) <- environment
# this is identical to
eco[["E"]] <- environment
#----------------------------------------------------------
# See additional examples in help("EcoGenetics accessors")
#----------------------------------------------------------
# Storing data in the slot OUT
singers <- c("carlos_gardel", "billie_holiday")
ecoslot.OUT(eco) <- singers
# Storing several datasets
golden.number <- (sqrt(5) + 1) / 2
ecoslot.OUT(eco) <- list(singers, golden.number) # several objects must be passed as a list
# this is identical to:
eco[["OUT"]] <- list(singers, golden.number)
#---------------------------------
# Locked and unlocked objects
#---------------------------------
is.locked(eco) # check if object is locked
eco[["P"]] <- rbind(eco[["P"]], eco[["P"]]) # invalid
# in locked object
eco_unlocked <- eco.unlock(eco) #unlocked object
eco_unlocked[["P"]]<-rbind(eco[["P"]], eco[["P"]]) # valid now
new_locked <- eco.lock(eco_unlocked) # invalid
eco_unlocked[["P"]]<- eco[["P"]]
new_locked <- eco.lock(eco_unlocked) # valid now
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab