if (FALSE) {
library(embryogrowth)
data(nest)
formated <- FormatNests(data=nest, previous=NULL, col.Time="Time")
# If I try to add the same nest, I have an error
formated <- FormatNests(data=nest, previous=formated, col.Time="Time")
# I duplicate the database and change the names
nest_duplicate <- nest
colnames(nest_duplicate) <- paste0(colnames(nest_duplicate), "_essai")
formated <- FormatNests(data=nest_duplicate, previous=formated, col.Time="Time_essai")
# It is possible to add information about these nests
formated <- FormatNests(data=nest, previous=NULL, col.Time="Time")
formated <- UpdateNests(data=formated, Males=c(DY.1=10), Females=c(DY.1=2))
####################
Laying.Time <- matrix(c("DY.1", "15/05/2010",
"DY.17", "24/05/2010",
"DY.16", "24/05/2010",
"DY.18", "25/05/2010",
"DY.20", "25/05/2010",
"DY.21", "26/05/2010",
"DY.22", "26/05/2010",
"DY.23", "26/05/2010",
"DY.24", "27/05/2010",
"DY.25", "27/05/2010",
"DY.28", "28/05/2010",
"DY.26", "28/05/2010",
"DY.27", "28/05/2010",
"DY.146", "20/06/2010",
"DY.147", "20/06/2010",
"DY.172", "24/06/2010",
"DY.175", "24/06/2010",
"DY.170", "24/06/2010",
"DY.260", "06/07/2010",
"DY.282", "12/07/2010",
"DY.310", "18/07/2010",
"DY.309", "18/07/2010",
"DY.328", "25/07/2010",
"DY.331", "26/07/2010"), byrow=TRUE, ncol=2)
tz <- OlsonNames()[grepl("Asia/Istanbul", OlsonNames())]
Laying.Time_f <- setNames(as.POSIXlt.character(Laying.Time[, 2], format = "%d/%m/%Y", tz=tz),
Laying.Time[, 1])
formated <- FormatNests(data=nest, previous=NULL, col.Time="Time", LayingTime=Laying.Time_f)
####################
# Now when the data are with absolute dates that are already formatted
nest_ec <- data.frame(Time=as.POSIXlt("24/05/2010", format="%d/%m/%Y")+ nest[, 1]*60,
DY.1.x=nest[, 2])
formated <- FormatNests(data=nest_ec, previous=NULL, col.Time="Time")
####################
# Now when the data are with absolute date that are in text format for example after
# reading a csv format
nest_ec <- data.frame(Time=format(as.POSIXlt("24/05/2010", format="%d/%m/%Y")+ nest[, 1]*60,
format = "%d/%m/%Y %H:%M:%S"),
DY.1.x=nest[, 2])
formated <- FormatNests(data=nest_ec, previous=NULL, col.Time="Time",
Time.Format="%d/%m/%Y %H:%M:%S",
Time.Zone=OlsonNames()[grepl("Asia/Istanbul", OlsonNames())],
hatchling.metric.mean=39.33, hatchling.metric.sd=1.92)
}
Run the code above in your browser using DataLab