diff --git a/examples_fun_comp_2d.R b/examples_fun_comp_2d.R new file mode 100644 index 0000000000000000000000000000000000000000..ebd2ba6bf643a0688fbb30c1e4f14cdc95b07008 --- /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) +