Skip to content
Snippets Groups Projects
Commit cf072112 authored by maufrais's avatar maufrais
Browse files

fun_comp_2d() example file

parent b525083a
Branches
No related tags found
No related merge requests found
######## 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment