Created
June 10, 2022 04:31
-
-
Save sjgknight/187badca4ad0f1e506ea426da21a6807 to your computer and use it in GitHub Desktop.
some very preliminary notes for a function to create a personal visualisation for students (and they can pick which one they like) based on name, etc. inputs (which, note, makes them opaque but reidentifiable)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: "Who are you?" | |
| output: html_notebook | |
| editor_options: | |
| chunk_output_type: inline | |
| --- | |
| Takes as input name, etc. | |
| Outputs visualisations | |
| ## Setup | |
| ```{r setup} | |
| library(pacman) | |
| p_load(kandinsky,morsecode, phonenumber, secrettext,tibble,ggplot2) | |
| ############## | |
| #converts letters to numbers | |
| letter2num <- function(x) {utf8ToInt(x) - utf8ToInt("a") + 1L} | |
| LETTER2num <- function(x) {utf8ToInt(x) - utf8ToInt("A") + 1L} | |
| #unname(sapply("ABC", LETTER2num)) | |
| let2n <- function(x) { | |
| x <- unlist(strsplit(x, split = "")) | |
| sapply(x, function(y) { | |
| unlist(strsplit(y, split = "")) | |
| if(grepl("[[:upper:]]", y)) { | |
| LETTER2num(y) | |
| } else { | |
| letter2num(y) | |
| } | |
| } ) } | |
| ``` | |
| ## Kandinsky my name | |
| ```{r} | |
| df <- kandinsky:::normalizeAndVectorize( | |
| data.frame( | |
| your_name = c("Simon", "James","goodwin","Knight"), | |
| course = c("Masters of", "Data", "Science and", "Innovation"), | |
| uni = c("University"," of", "Technology"," Sydney"), | |
| grade = c(1,2,6,4), | |
| check.rows = F, | |
| stringsAsFactors = T)) %>% rep(50) | |
| kandinsky::kandinsky(df) | |
| name <- "Simon James Goodwin Knight" | |
| nm <- unlist(stringr::str_split(name, " ")) | |
| m <- morsecode::text_to_morse_numeric(name) | |
| morse_seg <- unlist(morsecode:::text_to_morse_segments(name)) | |
| lets <- unlist(strsplit(name, split = "")) | |
| alph <- as.numeric(let2n(name)) | |
| phone <- as.numeric(letterToNumber(name)) | |
| shift_sub_cipher <- secrettext::setcode(name, LETTER2num(lets[1]), letter2num(lets[c(nchar(name))])) | |
| dist <- as.numeric(stringdist::stringdist(shift_sub_cipher,lets)) | |
| kd <- tibble(data = (c(name,nm,m,morse_seg,lets,alph,phone,shift_sub_cipher,dist))) | |
| kandinsky:::zeroOneNormalize(kd) | |
| kandinsky(kd) | |
| ggsave("kd.png") | |
| #lapply(nm, text_to_morse_segments) | |
| ``` | |
| ## Or as morse | |
| ```{r} | |
| tm_viz <- text_to_morse_segments(name, line_length = 5) %>% | |
| ggplot(aes(x = x, xend = xend, y = y, yend = yend, | |
| color = sample(group))) + | |
| geom_segment(size = 3, show.legend = FALSE) + | |
| theme_void() + | |
| scale_color_viridis_c() | |
| tm_viz | |
| ``` | |
| ### combine | |
| ```{r} | |
| #ggbackground(tm_viz,"kd.png") | |
| ``` | |
| ## Others to play with | |
| ```{r} | |
| p_load(aRtsy) | |
| aRtsy::canvas_collatz(colors = '#ff2305', background = '#b2b2b2', n = 40, | |
| angle.even = 0.0075, angle.odd = 0.0145, side = TRUE) | |
| #you might enjoy exzploring some of these, although it'd take some work with some of them to use your own data (rather than randomly generated data) | |
| #library(pacman) | |
| #p_load_gh("djnavarro/damage","djnavarro/flametree","cutterkom/generativeart","thomasp85/ambient","djnavarro/jasmines","marcusvolz/mathart","Ijeamakaanyene/contouR","koenderks/aRtsy") | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment