priviere / PPBstats

A R package for Participatory Plant Breeding statisticial analyses
https://priviere.github.io/PPBstats_web_site/
9 stars 8 forks source link

Add the date in format of data #48

Closed priviere closed 7 years ago

priviere commented 7 years ago
priviere commented 7 years ago

update for

priviere commented 7 years ago

# data_GxE ----------
data("data_GxE")
data_GxE$"y1$date" = NA
data_GxE$"y1$date"[which(data_GxE$location == "L1")] = "2017-07-15"
data_GxE$"y1$date"[which(data_GxE$location == "L2")] = "2017-07-06"
data_GxE$"y1$date"[which(data_GxE$location == "L3")] = "2017-07-22"

data_GxE$"y2$date" = NA
data_GxE$"y2$date"[which(data_GxE$location == "L1")] = "2017-07-15"
data_GxE$"y2$date"[which(data_GxE$location == "L2")] = "2017-07-06"
data_GxE$"y2$date"[which(data_GxE$location == "L3")] = "2017-07-22"

data_GxE$"y3$date" = NA
data_GxE$"y3$date"[which(data_GxE$location == "L1")] = "2017-07-15"
data_GxE$"y3$date"[which(data_GxE$location == "L2")] = "2017-07-06"
data_GxE$"y3$date"[which(data_GxE$location == "L3")] = "2017-07-22"

data_GxE = cbind.data.frame(
  "location" = data_GxE$"location",
  "year" = data_GxE$"year",
  "germplasm" = data_GxE$"germplasm",
  "block" = data_GxE$"block",
  "X" = data_GxE$"X",
  "Y" = data_GxE$"Y",
  "y1" = data_GxE$"y1",
  "y1$date" = data_GxE$"y1$date",
  "y2" = data_GxE$"y2",
  "y2$date" = data_GxE$"y2$date",
  "y3" = data_GxE$"y3",
  "y3$date" = data_GxE$"y3$date"
  )

save(data_GxE, file = "./data/data_GxE.RData")

# data_model_1 ----------

data("data_model_1")
data_model_1$"tkw$date" = NA

vec_dates = c("2017-07-02",
"2017-07-06",
"2017-07-10",
"2017-07-15",
"2017-07-21",
"2017-07-22",
"2017-07-28",
"2017-07-29",
"2017-07-31")

a = sample(vec_dates, nlevels(data_model_1$location), replace = TRUE)
names(a) = levels(data_model_1$location)
data_model_1$"tkw$date" = a[data_model_1$location]

data_model_1 = cbind.data.frame(
  "location" = data_model_1$"location",
  "year" = data_model_1$"year",
  "germplasm" = data_model_1$"germplasm",
  "block" = data_model_1$"block",
  "X" = data_model_1$"X",
  "Y" = data_model_1$"Y",
  "tkw" =  data_model_1$"tkw",
  "tkw$date" =  data_model_1$"tkw$date",
  "mu_ij" =  data_model_1$"mu_ij",
  "beta_jk" =  data_model_1$"beta_jk",
  "epsilon_ijk" =  data_model_1$"epsilon_ijk",
  "sigma_j" =  data_model_1$"sigma_j"
  )

save(data_model_1, file = "./data/data_model_1.RData")

# data_model_2 ----------

data("data_model_2")
data_model_2$"y1$date" = NA
data_model_2$"y2$date" = NA
data_model_2$"y3$date" = NA

a = sample(vec_dates, nlevels(data_model_2$location), replace = TRUE)
names(a) = levels(data_model_2$location)
data_model_2$"y1$date" = a[data_model_2$location]

a = sample(vec_dates, nlevels(data_model_2$location), replace = TRUE)
names(a) = levels(data_model_2$location)
data_model_2$"y2$date" = a[data_model_2$location]

a = sample(vec_dates, nlevels(data_model_2$location), replace = TRUE)
names(a) = levels(data_model_2$location)
data_model_2$"y3$date" = a[data_model_2$location]

data_model_2 = cbind.data.frame(
  "location" = data_model_2$"location",
  "year" = data_model_2$"year",
  "germplasm" = data_model_2$"germplasm",
  "block" = data_model_2$"block",
  "X" = data_model_2$"X",
  "Y" = data_model_2$"Y",
  "y1" =  data_model_2$"y1",
  "y1$date" =  data_model_2$"y1$date",
  "alpha_i-1" =  data_model_2$"alpha_i-1",
  "beta_i-1" =  data_model_2$"beta_i-1",
  "theta_j-1" =  data_model_2$"theta_j-1",
  "y2" = data_model_2$"y2",
  "y2$date" = data_model_2$"y2$date",
  "y3" = data_model_2$"y3",
  "y3$date" = data_model_2$"y3$date"
)

save(data_model_2, file = "./data/data_model_2.RData")