From cf0721129d5711592a18ed071678ef95e3937622 Mon Sep 17 00:00:00 2001 From: maufrais <maufrais@pasteur.fr> Date: Fri, 15 Jan 2021 16:43:53 +0100 Subject: [PATCH] fun_comp_2d() example file --- examples_fun_comp_2d.R | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples_fun_comp_2d.R diff --git a/examples_fun_comp_2d.R b/examples_fun_comp_2d.R new file mode 100644 index 0000000..ebd2ba6 --- /dev/null +++ b/examples_fun_comp_2d.R @@ -0,0 +1,25 @@ + + + + + +######## fun_comp_2d() #### comparison of two 2D datasets (row & col names, dimensions, etc.) + +### Datasets +mat1 <- matrix(1:10, ncol = 5, dimnames = list(letters[1:2], LETTERS[1:5])) ; # 2D matrix of integers +mat2 <- matrix(1:1e6, ncol = 5, dimnames = list(NULL, LETTERS[1:5])) ; head(mat2) ; # large matrix of integers +data1 <- as.data.frame(matrix(1:10, ncol = 5, dimnames = list(letters[1:2], LETTERS[1:5])), stringsAsFactors = TRUE) ; #data frame of integers +tab1 <- data.frame(A = 1:3, B= letters[1:3], stringsAsFactors = TRUE)# table of integers + +mat3 = matrix(1:1e6, ncol = 5, dimnames = list(NULL, LETTERS[1:5])) ; head(obs1) ; # 2D matrix of integers +mat4 = matrix((1:1e6)+1e6/5, ncol = 5, dimnames = list(NULL, LETTERS[1:5])) ; head(obs2) # 2D matrix of integers + +### Datasets info + +### Simple example +fun_comp_2d(data1 = mat1, data2 = mat1) # comparison of 2D matrices +fun_comp_2d(data1 = mat1, data2 = mat2 ) # comparison of 2D matrices +fun_comp_2d(data1 = mat1, data2 = data1) # comparison of matrix and dataframe +fun_comp_2d(data1 = data1, data2 = tab1) # comparison of matrix and table +fun_comp_2d(data1 = mat3, data2 = mat4) # comparison of 2D matrices; WARNING: when comparing content (rows, columns, or total), double and integer data are considered as different -> double(1) != integer(1) + -- GitLab