require(vegan)

bacteria <- read.csv("data-raw/bacteria.csv",
  header = TRUE,
  row.names = 1,
  na.strings = "NA"
)

eukaryotes <- read.csv("data-raw/eukaryotes.csv",
  header = TRUE,
  row.names = 1,
  na.strings = "NA"
)

climat <- read.csv("data-raw/climat.csv",
  header = TRUE,
  row.names = 1,
  na.strings = "NA"
)

soil <- read.csv("data-raw/soil.csv",
  header = TRUE,
  row.names = 1,
  na.strings = "NA"
)

geography <- read.csv("data-raw/geography.csv",
  header = TRUE,
  row.names = 1,
  na.strings = "NA"
)

usethis::use_data(bacteria, overwrite = TRUE)
usethis::use_data(eukaryotes, overwrite = TRUE)
usethis::use_data(climat, overwrite = TRUE)
usethis::use_data(soil, overwrite = TRUE)
usethis::use_data(geography, overwrite = TRUE)

#
# MicroCurvulatum datasets
#

mc.bacteria <- read.table("data-raw/MicroCurvulatum/rarefied_bacterial_community_matrix.txt",
  row.names = 1,
  header = 1,
  na.strings = "NA"
)

mc.bacteria = as.matrix(mc.bacteria)

mc.fungi <- read.table("data-raw/MicroCurvulatum/rarefied_fungal_community_matrix.txt",
  row.names = 1,
  header = 1,
  na.strings = "NA"
)

mc.fungi <- as.matrix(mc.fungi[row.names(mc.bacteria),])

mc.plants <- read.table("data-raw/MicroCurvulatum/Phytosocio.txt",
  row.names = 1,
  header = 1,
  na.strings = "NA"
)

mc.plants <- as.matrix(mc.plants[substr(row.names(mc.bacteria),
                              1,
                              nchar(row.names(mc.bacteria))-1),])

mc.soil <- read.table("data-raw/MicroCurvulatum/SOIL_CHEM.txt",
  row.names = 1,
  header = 1,
  na.strings = "NA"
)

mc.soil <- as.matrix(mc.soil[row.names(mc.bacteria),5:10])

MicroCurvulatum = ProcMod::procmod.frame(bacteria = mc.bacteria,
                                         fungi = mc.fungi,
                                         plants = mc.plants,
                                         soil = mc.soil)

usethis::use_data(MicroCurvulatum, overwrite = TRUE)
