comparison graph_stat_presence_abs.r @ 1:8e8867bf491a draft default tip

"planemo upload for repository https://github.com/Marie59/Data_explo_tools commit 60627aba07951226c8fd6bb3115be4bd118edd4e"
author ecology
date Fri, 13 Aug 2021 18:18:00 +0000
parents c7dd4706f982
children
comparison
equal deleted inserted replaced
0:c7dd4706f982 1:8e8867bf491a
18 hr <- args[2] 18 hr <- args[2]
19 var <- as.numeric(args[3]) 19 var <- as.numeric(args[3])
20 spe <- as.numeric(args[4]) 20 spe <- as.numeric(args[4])
21 loc <- as.numeric(args[5]) 21 loc <- as.numeric(args[5])
22 time <- as.numeric(args[6]) 22 time <- as.numeric(args[6])
23 source(args[7])
23 } 24 }
24 25
25 if (hr == "false") { 26 if (hr == "false") {
26 hr <- FALSE 27 hr <- FALSE
27 }else{ 28 }else{
35 colspe <- colnames(data)[spe] 36 colspe <- colnames(data)[spe]
36 colloc <- colnames(data)[loc] 37 colloc <- colnames(data)[loc]
37 coltime <- colnames(data)[time] 38 coltime <- colnames(data)[time]
38 39
39 data <- data[grep("^$", data[, spe], invert = TRUE), ] 40 data <- data[grep("^$", data[, spe], invert = TRUE), ]
40 time <- as.integer(substring(data[, time], first = 1, last = 4))
41 41
42 #####Your analysis 42 #####Your analysis
43 43
44 ####Median and data dispersion#### 44 ####Median and data dispersion####
45 45
73 73
74 74
75 #### Zero problem in data #### 75 #### Zero problem in data ####
76 76
77 #Put data in form 77 #Put data in form
78 make_table_analyse <- function(data, var, spe, var2, var3) {
79 tab <- reshape(data
80 , v.names = var
81 , idvar = c(var2, var3)
82 , timevar = spe
83 , direction = "wide")
84 tab[is.na(tab)] <- 0 ###### remplace les na par des 0 / replace NAs by 0
85 78
86 colnames(tab) <- sub(var, "", colnames(tab))### remplace le premier pattern "abond." par le second "" / replace the column names "abond." by ""
87 return(tab)
88 }
89 data_num <- make_table_analyse(data, colvar, colspe, colloc, coltime) 79 data_num <- make_table_analyse(data, colvar, colspe, colloc, coltime)
90 nb_spe <- length(unique(data[, spe])) 80 nb_spe <- length(unique(data[, spe]))
91 nb_col <- ncol(data_num) - nb_spe + 1 81 nb_col <- ncol(data_num) - nb_spe + 1
92 data_num <- data_num[, nb_col:ncol(data_num)] 82 data_num <- data_num[, nb_col:ncol(data_num)]
93 83