This is NicheToolBox environmental data report here you can find a quick view of the thinks that you have done in the software. Remember that this is free software so it comes with no waranty, please report any bugs you find at luismurao@gmail.com or via projects GitHub repository https://github.com/luismurao/ntbox.

library(knitr)
library(rgl)
knitr::opts_chunk$set(echo = TRUE)
knit_hooks$set(rgl = hook_rgl, webgl = hook_webgl)
#rgl.open()
library(knitr)
niche_data <- data_extraction()
if(!is.null(niche_data)){
  cat("## Niche data")
  cat("\n")
  cat(paste0("The total number niche records were: **", 
             dim(niche_data)[1],"**"))

  cat("\n\n")

  cat(paste0("The total number of niche variables is: ",
             dim(niche_data)[2],":"), names(niche_data))
  cat("\n")

  printInfoNiche <- TRUE

} else{
  printInfoNiche <- FALSE
}
niche_data <- data_extraction()
if(!is.null(niche_data)){
  cat("## Niche values")
  cat("\n")
  cat("#### Raster layeres ")
  printInfoNiche <- TRUE
} else{
  printInfoNiche <- FALSE
}
print(rasterLayers())
cat("Raster plot showing 1 layer")
#plot(rasterLayers()[[1]])
cat("#### Niche values of", ifelse(input$extracted_area== "all_area",print("All raster area"),print("M polygon area")))
cat("using", ifelse(input$datasetM== "gbif_dat",print("GBIF data"), print("User data")))
cat("### Niche data summary")
niche_data <- data_extraction()
summary(niche_data)
if(!is.null(data_extraction())){
  cont <- 1 
  nvars <- dim(data_extraction())[2]
  if(nvars > 7){
      for(i in 1:nvars){
        if(i%%7==0){
          print(kable(summary(data_extraction()[,cont:i])))
          cont <- i + 1
          }
        }
  }
  lprint <- data_extraction()[,cont:nvars]
  names(lprint) <- names(data_extraction())[cont:nvars]
  kable(summary(lprint))
}
niche_data <- niche_data()
gtype <- input$gtype
x <- input$x
y <- input$y
z <- input$z
ajus <- input$fit
ellip <- input$ellip
prop <- as.numeric(input$ellipsoid_vol)
if(!is.null(niche_data())){
  rgl::par3d(cex = 0.8)
  niche_plot(data = niche_data,x = x,y = y,z = z,prop =prop,
             gtype = gtype,ajus = ajus,ellip = ellip)
  rgl::rgl.close()
}
if(!is.null(corr_table())){
  printInfoCorre <- 1 
} else printInfoCorre <- 0
cat("## Niche correlations")
cat("### Correlation matrix")
corre_mat <- corr_table()
print(corre_mat)
if(!is.null(corr_table())){
  corre_mat <- round(corr_table(),3)
  print(kable(corre_mat))
}
cat("### Correlation finder")
cat("Strong correlations according to a correlation threshold of", input$cor_threshold)
cor_vars  <- correlation_finder(cor_mat = corre_mat,
                                threshold = input$cor_threshold,
                                verbose = FALSE)
print(cor_vars)
cat("### Correlogram")
col1 <- colorRampPalette(
      c("#7F0000","red","#FF7F00","yellow","white",
        "cyan", "#007FFF", "blue","#00007F"))
corrplot(corre_mat,
         method="ellipse",
         col=col1(200),order = "AOE")
loaded_km <- input$load_kmeas_vars
if(loaded_km >0L){
  if(!is.null(kmeans_df()))
    printInfoKmeans <- 1 
  else 
    printInfoKmeans <- 0
} else printInfoKmeans <- 0
cat("## K-means clustering")

nclusters <- length(unique(kmeans_3d_plot_data()$cluster_ids))
cat(paste0("Total number of clusters ", "**",nclusters,"**"))
k_means_df <- kmeans_df()
k_means_df <- kmeans_df()
if(!is.null(k_means_df)){
  cont <- 1 
nvars <- dim(kmeans_df())[2]
if(nvars > 7){
    for(i in 1:nvars){
      if(i%%7==0){
        print(kable(head(kmeans_df()[,cont:i])))
        cont <- i + 1
      }
    }
} else{
print(kable(head(kmeans_df())))
}
}
printKmeansPlot <- 0
if(input$load_kmeas_vars){
  k_means_plot <- kmeans_3d_plot_data()
  if(!is.null(k_means_plot)){
   printKmeansPlot <- 1 
  }
}
cat("### K-means clustering (niche space)")
ellipsoid_cluster_plot_3d(niche_data = kmeans_3d_plot_data()$data,
                                cluster_ids = kmeans_3d_plot_data()$cluster_ids,
                                vgrupo = kmeans_3d_plot_data()$vgrupo,
                                x = input$x1,y = input$y1,
                                z = input$z1,alpha = input$alpha,ellips = input$ellips,
                                grupos=input$grupos,input$cex1,level=input$kmeans_level)
cat("### K-means clustering (Geographic space)")
leaflet_cluster_map()


luismurao/ntbox documentation built on May 9, 2024, 8:24 p.m.