diff functions.r @ 1:3df8937fd6fd draft default tip

"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
author ecology
date Fri, 13 Aug 2021 18:16:46 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/functions.r	Fri Aug 13 18:16:46 2021 +0000
@@ -0,0 +1,22 @@
+#Rscript
+
+#########################################################################################
+####################### Exploration data tools function #################################
+#########################################################################################
+#### Based on Romain Lorrillière R script
+#### Modified by Alan Amosse, Benjamin Yguel and Marie Jossé for integrating within Galaxy-E
+
+######################################### start of the function makeTableAnalyse
+##Species are placed in separated columns and addition of zero on plots where at least one selected species is present
+make_table_analyse <- function(data, var, spe, var2, var3) {
+    tab <- reshape(data
+                  , v.names = var
+                  , idvar = c(var2, var3)
+                  , timevar = spe
+                  , direction = "wide")
+    tab[is.na(tab)] <- 0 ###### remplace les na par des 0 / replace NAs by 0
+
+    colnames(tab) <- sub(paste0(var, "."), "", colnames(tab))### remplace le premier pattern "abond." par le second "" / replace the column names "abond." by ""
+    return(tab)
+}
+######################################### end of the function makeTableAnalyse