diff --git a/index.html b/index.html index 4397a3a..26d7491 100644 --- a/index.html +++ b/index.html @@ -110,19 +110,16 @@

Exampledraw_matrix(mat_3x5)

-# Disable showing the cell indices
-draw_matrix(mat_3x5, show_cell_indices = FALSE)
+# Show the cell indices +draw_matrix(mat_3x5, show_cell_indices = TRUE)

-# Disable showing any indices
-draw_matrix(
-  mat_3x5, 
-  show_row_indices = TRUE, show_column_indices = TRUE,
-  show_cell_indices = FALSE)
+# Show the row and column indices +draw_matrix(mat_3x5, show_row_indices = TRUE, show_column_indices = TRUE)

 # Highlight cells over a specific value
-draw_matrix(mat_3x5, highlight_cells = mat_3x5 > 4)
+draw_matrix(mat_3x5, highlight_area = mat_3x5 > 4)

We can achieve similar results with the ggplot2 function.

@@ -130,9 +127,8 @@ 

Examplegdraw_matrix(mat_3x5)

-
-# Highlight cells over a specific value
-gdraw_matrix(mat_3x5, highlight_cells = mat_3x5 > 4)
+# Highlight cells in specific columns +gdraw_matrix(mat_3x5, highlight_area = highlight_columns(mat_3x5, columns = 2:4))

diff --git a/pkgdown.yml b/pkgdown.yml index d99e511..9053e60 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 2.19.2 pkgdown: 2.0.7 pkgdown_sha: ~ articles: {} -last_built: 2024-01-11T11:04Z +last_built: 2024-01-13T07:37Z urls: reference: http://r-pkg.thecoatlessprofessor.com/drawr/reference article: http://r-pkg.thecoatlessprofessor.com/drawr/articles diff --git a/reference/Rplot002.png b/reference/Rplot002.png index b7c39b1..c007461 100644 Binary files a/reference/Rplot002.png and b/reference/Rplot002.png differ diff --git a/reference/Rplot003.png b/reference/Rplot003.png index 596e038..dccee7f 100644 Binary files a/reference/Rplot003.png and b/reference/Rplot003.png differ diff --git a/reference/Rplot004.png b/reference/Rplot004.png index 7179264..51f4251 100644 Binary files a/reference/Rplot004.png and b/reference/Rplot004.png differ diff --git a/reference/Rplot005.png b/reference/Rplot005.png index 3fb27fc..717dd91 100644 Binary files a/reference/Rplot005.png and b/reference/Rplot005.png differ diff --git a/reference/Rplot007.png b/reference/Rplot007.png index 09df2a5..1d7db41 100644 Binary files a/reference/Rplot007.png and b/reference/Rplot007.png differ diff --git a/reference/Rplot008.png b/reference/Rplot008.png index 5daf84d..bb4f11b 100644 Binary files a/reference/Rplot008.png and b/reference/Rplot008.png differ diff --git a/reference/draw-matrix-1.png b/reference/draw-matrix-1.png index 4682077..61c7b5e 100644 Binary files a/reference/draw-matrix-1.png and b/reference/draw-matrix-1.png differ diff --git a/reference/draw-matrix-2.png b/reference/draw-matrix-2.png index 61c7b5e..4682077 100644 Binary files a/reference/draw-matrix-2.png and b/reference/draw-matrix-2.png differ diff --git a/reference/draw-matrix-3.png b/reference/draw-matrix-3.png index f58d910..884d119 100644 Binary files a/reference/draw-matrix-3.png and b/reference/draw-matrix-3.png differ diff --git a/reference/draw-matrix-4.png b/reference/draw-matrix-4.png index 46e8230..3debfdb 100644 Binary files a/reference/draw-matrix-4.png and b/reference/draw-matrix-4.png differ diff --git a/reference/draw-matrix-5.png b/reference/draw-matrix-5.png index 2ad87e5..b4f85f8 100644 Binary files a/reference/draw-matrix-5.png and b/reference/draw-matrix-5.png differ diff --git a/reference/draw-matrix-7.png b/reference/draw-matrix-7.png index 819931a..806e265 100644 Binary files a/reference/draw-matrix-7.png and b/reference/draw-matrix-7.png differ diff --git a/reference/draw-matrix-8.png b/reference/draw-matrix-8.png index d175b1c..0ee0f68 100644 Binary files a/reference/draw-matrix-8.png and b/reference/draw-matrix-8.png differ diff --git a/reference/draw-matrix.html b/reference/draw-matrix.html index e37e30c..b64a72e 100644 --- a/reference/draw-matrix.html +++ b/reference/draw-matrix.html @@ -50,19 +50,19 @@

Usage

draw_matrix(
   data,
-  show_cell_indices = TRUE,
+  show_cell_indices = FALSE,
   show_row_indices = FALSE,
   show_column_indices = FALSE,
-  highlight_cells = matrix(FALSE, nrow(data), ncol(data)),
+  highlight_area = matrix(FALSE, nrow(data), ncol(data)),
   highlight_color = "lemonchiffon"
 )
 
 gdraw_matrix(
   data,
-  show_cell_indices = TRUE,
+  show_cell_indices = FALSE,
   show_row_indices = FALSE,
   show_column_indices = FALSE,
-  highlight_cells = matrix(FALSE, nrow(data), ncol(data)),
+  highlight_area = matrix(FALSE, nrow(data), ncol(data)),
   highlight_color = "lemonchiffon"
 )
@@ -74,7 +74,7 @@

ArgumentsArgumentsExamplesdraw_matrix(mat_3x3) -# Disable the indices -draw_matrix(mat_3x3, show_cell_indices = FALSE) +# Show the indices +draw_matrix(mat_3x3, show_cell_indices = TRUE) # Highlight a row -mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) -mat_2x2_mask = matrix(c(TRUE, TRUE, FALSE, FALSE), nrow = 2) -draw_matrix(mat_2x2, highlight_cells = mat_2x2_mask) +mat_4x4 = matrix(seq_len(16), nrow = 4) +draw_matrix( + mat_4x4, + show_row_indices = TRUE, highlight_area = highlight_rows(mat_4x4, rows = 1)) # Highlight values above 5 -mat_3x5 = matrix(rnorm(15, 5, 2), ncol = 5) -draw_matrix(mat_3x5, highlight_cells = mat_3x5 > 2) +mat_2x4 = matrix(round(rnorm(16, 5, 2), 2), ncol = 4) +draw_matrix(mat_2x4, highlight_area = mat_2x4 > 2) # ggplot2 graphics ---- # Visualize a 3x3 @@ -126,18 +127,18 @@

Examples # View the matrix without indices present -gdraw_matrix(mat_3x3, show_cell_indices = FALSE) +gdraw_matrix(mat_3x3, highlight_area = FALSE) # Highlight a row mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) mat_2x2_mask = matrix(c(TRUE, TRUE, FALSE, FALSE), nrow = 2) -gdraw_matrix(mat_2x2, highlight_cells = mat_2x2_mask) +gdraw_matrix(mat_2x2, highlight_area = mat_2x2_mask) # Highlight values above 5 -mat_3x5 = matrix(rnorm(15, 5, 2), ncol = 5) -gdraw_matrix(mat_3x5, highlight_cells = mat_3x5 > 2) +mat_3x5 = matrix(round(rnorm(15, 5, 2), 2), ncol = 5) +gdraw_matrix(mat_3x5, highlight_area = mat_3x5 > 2) diff --git a/reference/figures/README-base-example-1.png b/reference/figures/README-base-example-1.png index 820e39a..f7608b8 100644 Binary files a/reference/figures/README-base-example-1.png and b/reference/figures/README-base-example-1.png differ diff --git a/reference/figures/README-base-example-2.png b/reference/figures/README-base-example-2.png index f7608b8..820e39a 100644 Binary files a/reference/figures/README-base-example-2.png and b/reference/figures/README-base-example-2.png differ diff --git a/reference/figures/README-base-example-4.png b/reference/figures/README-base-example-4.png index c4e3bfd..ed77ff7 100644 Binary files a/reference/figures/README-base-example-4.png and b/reference/figures/README-base-example-4.png differ diff --git a/reference/figures/README-ggplot2-example-1.png b/reference/figures/README-ggplot2-example-1.png index 15c669f..62bc205 100644 Binary files a/reference/figures/README-ggplot2-example-1.png and b/reference/figures/README-ggplot2-example-1.png differ diff --git a/reference/figures/README-ggplot2-example-2.png b/reference/figures/README-ggplot2-example-2.png index 5ff61c2..a3e64ea 100644 Binary files a/reference/figures/README-ggplot2-example-2.png and b/reference/figures/README-ggplot2-example-2.png differ diff --git a/reference/highlight-data.html b/reference/highlight-data.html new file mode 100644 index 0000000..9bdfa53 --- /dev/null +++ b/reference/highlight-data.html @@ -0,0 +1,164 @@ + +Highlight a matrix — highlight_data • drawr + Skip to contents + + +
+
+
+ +
+

Generate a matrix with active areas.

+
+ +
+

Usage

+
highlight_data(x, rows = NULL, columns = NULL, locations = NULL)
+
+highlight_rows(x, rows = NULL)
+
+highlight_columns(x, columns = NULL)
+
+highlight_locations(x, locations = NULL)
+
+ +
+

Arguments

+
x
+

A matrix.

+ + +
rows
+

An interger vector with valid row index locations.

+ + +
columns
+

An integer vector containing valid column indexlocations.

+ + +
locations
+

An m by 2 matrix with points listed in x, y format.

+ +
+
+

Value

+ + +

A logical matrix with the required rows and/or columns or points set to +TRUE. All other values are given as FALSE.

+
+ +
+

Examples

+
# Example data
+x = matrix(1:12, nrow = 4)
+
+# Highlight points using an x, y pairing
+locations = rbind( 
+  c(1, 3), 
+  c(2, 2),
+  c(4, 1)
+)
+highlight_locations(x, locations)
+#>       [,1]  [,2]  [,3]
+#> [1,] FALSE FALSE  TRUE
+#> [2,] FALSE  TRUE FALSE
+#> [3,] FALSE FALSE FALSE
+#> [4,]  TRUE FALSE FALSE
+
+# Highlight entries only in the 1st and 3rd rows.
+highlight_rows(x, rows = c(1, 3))
+#>       [,1]  [,2]  [,3]
+#> [1,]  TRUE  TRUE  TRUE
+#> [2,] FALSE FALSE FALSE
+#> [3,]  TRUE  TRUE  TRUE
+#> [4,] FALSE FALSE FALSE
+
+# Highlight entries only in the first two rows:
+highlight_rows(x, rows = 1:2)
+#>       [,1]  [,2]  [,3]
+#> [1,]  TRUE  TRUE  TRUE
+#> [2,]  TRUE  TRUE  TRUE
+#> [3,] FALSE FALSE FALSE
+#> [4,] FALSE FALSE FALSE
+
+# Highlight entries in the last column
+highlight_columns(x, columns = ncol(x))
+#>       [,1]  [,2] [,3]
+#> [1,] FALSE FALSE TRUE
+#> [2,] FALSE FALSE TRUE
+#> [3,] FALSE FALSE TRUE
+#> [4,] FALSE FALSE TRUE
+
+# Highlight entries in the first column
+highlight_columns(x, columns = 1)
+#>      [,1]  [,2]  [,3]
+#> [1,] TRUE FALSE FALSE
+#> [2,] TRUE FALSE FALSE
+#> [3,] TRUE FALSE FALSE
+#> [4,] TRUE FALSE FALSE
+
+# Highlight entries in the first column or first row.
+highlight_data(x, rows = 1, columns = 1)
+#>      [,1]  [,2]  [,3]
+#> [1,] TRUE  TRUE  TRUE
+#> [2,] TRUE FALSE FALSE
+#> [3,] TRUE FALSE FALSE
+#> [4,] TRUE FALSE FALSE
+
+
+
+ + +
+ + + + + + + diff --git a/reference/index.html b/reference/index.html index f885338..a138bd7 100644 --- a/reference/index.html +++ b/reference/index.html @@ -58,7 +58,7 @@

All functionshighlight_matrix() + highlight_data() highlight_rows() highlight_columns() highlight_locations()
Highlight a matrix
diff --git a/search.json b/search.json index 1425633..c78a3bf 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"James Joseph Balamuta. Author, maintainer.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Balamuta J (2024). drawr: Create Graphics 'R' Data Structures. R package version 0.0.1, https://r-pkg.thecoatlessprofessor.com/drawr/, https://github.com/coatless-rpkg/drawr.","code":"@Manual{, title = {drawr: Create Graphics of 'R' Data Structures}, author = {James Joseph Balamuta}, year = {2024}, note = {R package version 0.0.1, https://r-pkg.thecoatlessprofessor.com/drawr/}, url = {https://github.com/coatless-rpkg/drawr}, }"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"drawr","dir":"","previous_headings":"","what":"Create Graphics of R Data Structures","title":"Create Graphics of R Data Structures","text":"goal drawr draw different R data structures graphs.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Create Graphics of R Data Structures","text":"can install development version drawr GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"coatless-rpkg/drawr\")"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"design","dir":"","previous_headings":"","what":"Design","title":"Create Graphics of R Data Structures","text":"package designed take advantage base R graphics alongside ggplot2. ’re providing two different implementations system naming scheme : draw_*(): base R graphics gdraw_*(): ggplot2","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Create Graphics of R Data Structures","text":"Take instance matrix looks like : wanted see contents layed indices? can achieve similar results ggplot2 function.","code":"mat_3x5 = matrix( c( 1, NA, 3, 4, NaN, NA, 7, 8, -9, 10, -11, 12, -Inf, -14, NA ), ncol = 5, byrow = TRUE) mat_3x5 #> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 NA 3 4 NaN #> [2,] NA 7 8 -9 10 #> [3,] -11 12 -Inf -14 NA # Load the library library(drawr) # Graphic of matrix data structure using base R graphics draw_matrix(mat_3x5) # Disable showing the cell indices draw_matrix(mat_3x5, show_cell_indices = FALSE) # Disable showing any indices draw_matrix( mat_3x5, show_row_indices = TRUE, show_column_indices = TRUE, show_cell_indices = FALSE) # Highlight cells over a specific value draw_matrix(mat_3x5, highlight_cells = mat_3x5 > 4) # Graphic of matrix data structure using base R graphics gdraw_matrix(mat_3x5) # Highlight cells over a specific value gdraw_matrix(mat_3x5, highlight_cells = mat_3x5 > 4)"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Visualize Data Inside of a Matrix — draw_matrix","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"Generate graph showing contents matrix.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"","code":"draw_matrix( data, show_cell_indices = TRUE, show_row_indices = FALSE, show_column_indices = FALSE, highlight_cells = matrix(FALSE, nrow(data), ncol(data)), highlight_color = \"lemonchiffon\" ) gdraw_matrix( data, show_cell_indices = TRUE, show_row_indices = FALSE, show_column_indices = FALSE, highlight_cells = matrix(FALSE, nrow(data), ncol(data)), highlight_color = \"lemonchiffon\" )"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"data object class matrix. show_cell_indices Display cell indices inside matrix cell, e.g. [, j]. Default: TRUE show_row_indices Display row indices next matrix row, e.g. [, ]. Default: FALSE show_column_indices Display column indices next matrix column, e.g. [, j]. Default: FALSE highlight_cells Matrix logical values provide mask cells filled. Default: None. highlight_color Color use fill background cell.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"","code":"# Base graphics # Visualize a 3x3 mat_3x3 = matrix(c(10, 200, -30, 40, 500, 30, 90, -55, 10), ncol = 3) draw_matrix(mat_3x3) # Disable the indices draw_matrix(mat_3x3, show_cell_indices = FALSE) # Highlight a row mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) mat_2x2_mask = matrix(c(TRUE, TRUE, FALSE, FALSE), nrow = 2) draw_matrix(mat_2x2, highlight_cells = mat_2x2_mask) # Highlight values above 5 mat_3x5 = matrix(rnorm(15, 5, 2), ncol = 5) draw_matrix(mat_3x5, highlight_cells = mat_3x5 > 2) # ggplot2 graphics ---- # Visualize a 3x3 mat_3x3 = matrix(c(10, 200, -30, 40, 500, 30, 90, -55, 10), ncol = 3) gdraw_matrix(mat_3x3) # View the matrix without indices present gdraw_matrix(mat_3x3, show_cell_indices = FALSE) # Highlight a row mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) mat_2x2_mask = matrix(c(TRUE, TRUE, FALSE, FALSE), nrow = 2) gdraw_matrix(mat_2x2, highlight_cells = mat_2x2_mask) # Highlight values above 5 mat_3x5 = matrix(rnorm(15, 5, 2), ncol = 5) gdraw_matrix(mat_3x5, highlight_cells = mat_3x5 > 2)"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/drawr-package.html","id":null,"dir":"Reference","previous_headings":"","what":"drawr: Create Graphics of 'R' Data Structures — drawr-package","title":"drawr: Create Graphics of 'R' Data Structures — drawr-package","text":"Visualize contents different 'R' data structures.","code":""},{"path":[]},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/drawr-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"drawr: Create Graphics of 'R' Data Structures — drawr-package","text":"Maintainer: James Joseph Balamuta james.balamuta@gmail.com (ORCID)","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Highlight a matrix — highlight_matrix","title":"Highlight a matrix — highlight_matrix","text":"Generate matrix active areas.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Highlight a matrix — highlight_matrix","text":"","code":"highlight_matrix(x, rows = NULL, columns = NULL, points = NULL)"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Highlight a matrix — highlight_matrix","text":"x matrix. rows interger vector valid row index locations. columns integer vector containing valid column indexlocations. points m 2 matrix points listed x, y format.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Highlight a matrix — highlight_matrix","text":"logical matrix required rows /columns points set TRUE. values given FALSE.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Highlight a matrix — highlight_matrix","text":"","code":"x = matrix(1:12, nrow = 4) # Highlight entries only in the 1st and 3rd rows. highlight_matrix(x, rows = c(1, 3)) #> [,1] [,2] [,3] #> [1,] TRUE TRUE TRUE #> [2,] FALSE FALSE FALSE #> [3,] TRUE TRUE TRUE #> [4,] FALSE FALSE FALSE # Highlight entries only in the first two rows: highlight_matrix(x, rows = 1:2) #> [,1] [,2] [,3] #> [1,] TRUE TRUE TRUE #> [2,] TRUE TRUE TRUE #> [3,] FALSE FALSE FALSE #> [4,] FALSE FALSE FALSE # Highlight entries in the last row highlight_matrix(x, rows = nrow(x)) #> [,1] [,2] [,3] #> [1,] FALSE FALSE FALSE #> [2,] FALSE FALSE FALSE #> [3,] FALSE FALSE FALSE #> [4,] TRUE TRUE TRUE # Highlight entries in the first column highlight_matrix(x, columns = 1) #> [,1] [,2] [,3] #> [1,] TRUE FALSE FALSE #> [2,] TRUE FALSE FALSE #> [3,] TRUE FALSE FALSE #> [4,] TRUE FALSE FALSE # Highlight entries in the first column or first row. highlight_matrix(x, rows = 1, columns = 1) #> [,1] [,2] [,3] #> [1,] TRUE TRUE TRUE #> [2,] TRUE FALSE FALSE #> [3,] TRUE FALSE FALSE #> [4,] TRUE FALSE FALSE"}] +[{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"James Joseph Balamuta. Author, maintainer.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Balamuta J (2024). drawr: Create Graphics 'R' Data Structures. R package version 0.0.1, https://r-pkg.thecoatlessprofessor.com/drawr/, https://github.com/coatless-rpkg/drawr.","code":"@Manual{, title = {drawr: Create Graphics of 'R' Data Structures}, author = {James Joseph Balamuta}, year = {2024}, note = {R package version 0.0.1, https://r-pkg.thecoatlessprofessor.com/drawr/}, url = {https://github.com/coatless-rpkg/drawr}, }"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"drawr","dir":"","previous_headings":"","what":"Create Graphics of R Data Structures","title":"Create Graphics of R Data Structures","text":"goal drawr draw different R data structures graphs.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Create Graphics of R Data Structures","text":"can install development version drawr GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"coatless-rpkg/drawr\")"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"design","dir":"","previous_headings":"","what":"Design","title":"Create Graphics of R Data Structures","text":"package designed take advantage base R graphics alongside ggplot2. ’re providing two different implementations system naming scheme : draw_*(): base R graphics gdraw_*(): ggplot2","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Create Graphics of R Data Structures","text":"Take instance matrix looks like : wanted see contents layed indices? can achieve similar results ggplot2 function.","code":"mat_3x5 = matrix( c( 1, NA, 3, 4, NaN, NA, 7, 8, -9, 10, -11, 12, -Inf, -14, NA ), ncol = 5, byrow = TRUE) mat_3x5 #> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 NA 3 4 NaN #> [2,] NA 7 8 -9 10 #> [3,] -11 12 -Inf -14 NA # Load the library library(drawr) # Graphic of matrix data structure using base R graphics draw_matrix(mat_3x5) # Show the cell indices draw_matrix(mat_3x5, show_cell_indices = TRUE) # Show the row and column indices draw_matrix(mat_3x5, show_row_indices = TRUE, show_column_indices = TRUE) # Highlight cells over a specific value draw_matrix(mat_3x5, highlight_area = mat_3x5 > 4) # Graphic of matrix data structure using base R graphics gdraw_matrix(mat_3x5) # Highlight cells in specific columns gdraw_matrix(mat_3x5, highlight_area = highlight_columns(mat_3x5, columns = 2:4))"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Visualize Data Inside of a Matrix — draw_matrix","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"Generate graph showing contents matrix.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"","code":"draw_matrix( data, show_cell_indices = FALSE, show_row_indices = FALSE, show_column_indices = FALSE, highlight_area = matrix(FALSE, nrow(data), ncol(data)), highlight_color = \"lemonchiffon\" ) gdraw_matrix( data, show_cell_indices = FALSE, show_row_indices = FALSE, show_column_indices = FALSE, highlight_area = matrix(FALSE, nrow(data), ncol(data)), highlight_color = \"lemonchiffon\" )"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"data object class matrix. show_cell_indices Display cell indices inside matrix cell, e.g. [, j]. Default: FALSE show_row_indices Display row indices next matrix row, e.g. [, ]. Default: FALSE show_column_indices Display column indices next matrix column, e.g. [, j]. Default: FALSE highlight_area Matrix logical values provide mask cells filled. Default: None. highlight_color Color use fill background cell.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/draw-matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Visualize Data Inside of a Matrix — draw_matrix","text":"","code":"# Base graphics # Visualize a 3x3 mat_3x3 = matrix(c(10, 200, -30, 40, 500, 30, 90, -55, 10), ncol = 3) draw_matrix(mat_3x3) # Show the indices draw_matrix(mat_3x3, show_cell_indices = TRUE) # Highlight a row mat_4x4 = matrix(seq_len(16), nrow = 4) draw_matrix( mat_4x4, show_row_indices = TRUE, highlight_area = highlight_rows(mat_4x4, rows = 1)) # Highlight values above 5 mat_2x4 = matrix(round(rnorm(16, 5, 2), 2), ncol = 4) draw_matrix(mat_2x4, highlight_area = mat_2x4 > 2) # ggplot2 graphics ---- # Visualize a 3x3 mat_3x3 = matrix(c(10, 200, -30, 40, 500, 30, 90, -55, 10), ncol = 3) gdraw_matrix(mat_3x3) # View the matrix without indices present gdraw_matrix(mat_3x3, highlight_area = FALSE) # Highlight a row mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) mat_2x2_mask = matrix(c(TRUE, TRUE, FALSE, FALSE), nrow = 2) gdraw_matrix(mat_2x2, highlight_area = mat_2x2_mask) # Highlight values above 5 mat_3x5 = matrix(round(rnorm(15, 5, 2), 2), ncol = 5) gdraw_matrix(mat_3x5, highlight_area = mat_3x5 > 2)"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/drawr-package.html","id":null,"dir":"Reference","previous_headings":"","what":"drawr: Create Graphics of 'R' Data Structures — drawr-package","title":"drawr: Create Graphics of 'R' Data Structures — drawr-package","text":"Visualize contents different 'R' data structures.","code":""},{"path":[]},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/drawr-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"drawr: Create Graphics of 'R' Data Structures — drawr-package","text":"Maintainer: James Joseph Balamuta james.balamuta@gmail.com (ORCID)","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight-data.html","id":null,"dir":"Reference","previous_headings":"","what":"Highlight a matrix — highlight_data","title":"Highlight a matrix — highlight_data","text":"Generate matrix active areas.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight-data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Highlight a matrix — highlight_data","text":"","code":"highlight_data(x, rows = NULL, columns = NULL, locations = NULL) highlight_rows(x, rows = NULL) highlight_columns(x, columns = NULL) highlight_locations(x, locations = NULL)"},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight-data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Highlight a matrix — highlight_data","text":"x matrix. rows interger vector valid row index locations. columns integer vector containing valid column indexlocations. locations m 2 matrix points listed x, y format.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight-data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Highlight a matrix — highlight_data","text":"logical matrix required rows /columns points set TRUE. values given FALSE.","code":""},{"path":"http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight-data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Highlight a matrix — highlight_data","text":"","code":"# Example data x = matrix(1:12, nrow = 4) # Highlight points using an x, y pairing locations = rbind( c(1, 3), c(2, 2), c(4, 1) ) highlight_locations(x, locations) #> [,1] [,2] [,3] #> [1,] FALSE FALSE TRUE #> [2,] FALSE TRUE FALSE #> [3,] FALSE FALSE FALSE #> [4,] TRUE FALSE FALSE # Highlight entries only in the 1st and 3rd rows. highlight_rows(x, rows = c(1, 3)) #> [,1] [,2] [,3] #> [1,] TRUE TRUE TRUE #> [2,] FALSE FALSE FALSE #> [3,] TRUE TRUE TRUE #> [4,] FALSE FALSE FALSE # Highlight entries only in the first two rows: highlight_rows(x, rows = 1:2) #> [,1] [,2] [,3] #> [1,] TRUE TRUE TRUE #> [2,] TRUE TRUE TRUE #> [3,] FALSE FALSE FALSE #> [4,] FALSE FALSE FALSE # Highlight entries in the last column highlight_columns(x, columns = ncol(x)) #> [,1] [,2] [,3] #> [1,] FALSE FALSE TRUE #> [2,] FALSE FALSE TRUE #> [3,] FALSE FALSE TRUE #> [4,] FALSE FALSE TRUE # Highlight entries in the first column highlight_columns(x, columns = 1) #> [,1] [,2] [,3] #> [1,] TRUE FALSE FALSE #> [2,] TRUE FALSE FALSE #> [3,] TRUE FALSE FALSE #> [4,] TRUE FALSE FALSE # Highlight entries in the first column or first row. highlight_data(x, rows = 1, columns = 1) #> [,1] [,2] [,3] #> [1,] TRUE TRUE TRUE #> [2,] TRUE FALSE FALSE #> [3,] TRUE FALSE FALSE #> [4,] TRUE FALSE FALSE"}] diff --git a/sitemap.xml b/sitemap.xml index 9fd2335..9e81ad2 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -16,7 +16,7 @@ http://r-pkg.thecoatlessprofessor.com/drawr/reference/drawr-package.html - http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight_matrix.html + http://r-pkg.thecoatlessprofessor.com/drawr/reference/highlight-data.html http://r-pkg.thecoatlessprofessor.com/drawr/reference/index.html