This file contains 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
# replace strings with mode case | |
require(dplyr) | |
case_lump = function(x){ | |
x1 = tibble::enframe(x, name=NULL) |> mutate(id = 1:n(), lower = tolower(value)) | |
x1 |> count(value, lower, sort = TRUE) |> | |
group_by(lower) |> slice(1) |> ungroup() |> | |
rename(mode = value) |> | |
left_join(x1, by = 'lower') |> |
This file contains 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
{ | |
"id": "0igifmdu25", | |
"product_class": "", | |
"process": "", | |
"source_type": "", | |
"product_category": "BIOGRAPHY", | |
"regions": [], | |
"primary_country_tag": "ZMB", | |
"topic_tags": [], | |
"country_tags_full": ["Zambia"], |
This file contains 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
require(rvest) | |
html_text_parent = function(x){ | |
x2 = rlang::duplicate(x, shallow = FALSE) | |
children = html_children(x2) | |
xml2::xml_remove(children) | |
txt = html_text(x2) | |
x = map(children, ~ xml2::xml_add_child(x, .value = .x)) | |
txt | |
} |
This file contains 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
{ | |
"responses": [ | |
{ | |
"faceAnnotations": [ | |
{ | |
"boundingPoly": { | |
"vertices": [ | |
{ | |
"x": 195, | |
"y": 130 |
This file contains 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
breed | name | owner | ticket | cabin | kenneled | survived | |
---|---|---|---|---|---|---|---|
King Charles Spaniel | NA | William Ernest Carter | 113760 | B96 B98 | TRUE | FALSE | |
Airedale Terrier | NA | William Ernest Carter | 113760 | B96 B98 | TRUE | FALSE | |
Chow Chow | Chow-Chow | Harry Anderson | 19952 | E12 | TRUE | FALSE | |
French Bulldog | Gamin de Pycombe | Robert Williams Daniel | 113804 | A | TRUE | FALSE | |
Airedale Terrier | Kitty | John Jacob Astor | 11754 | C62 | TRUE | FALSE | |
Pomeranian | Bebe/Lady | Margaret Bechstein Hays | 11767 | C54 | FALSE | TRUE | |
Pomeranian | NA | Elizabeth Jane Anne Rothschild | 17603 | C | FALSE | TRUE | |
Pekingese | Sun Yat Sen | Henry Sleeper Harper & Myra Raymond Harper | 17572 | D33 | FALSE | TRUE | |
toy dog | Freu Freu | Helen Margaret Bishop | 11967 | B49 | FALSE | FALSE |
This file contains 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
# remotes::install_github("moodymudskipper/safejoin") | |
require(safejoin) | |
require(tidyverse) | |
#> Loading required package: tidyverse | |
d1 = tibble(id = c(1,2,3), x = c('A','B','C'), y = c(5,7,9)) | |
d2 = tibble(id = c(2,3,4), x = c('B','CC','D'), y = c(7,9,11)) | |
safe_full_join(d1, d2, by = 'id', conflict = ~ coalesce(.y, .x)) |
This file contains 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
# string markdown to html conversion (HT https://github.com/matt-dray) | |
purrr::map_chr( | |
c("# title", "regular **bold**"), | |
~ markdown::renderMarkdown(text = .x) | |
) | |
#> [1] "<h1>title</h1>\n" | |
#> [2] "<p>regular <strong>bold</strong></p>\n" |
This file contains 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
library(tidyverse) | |
set.seed(7) | |
N = 1000 | |
x = rnorm(N) | |
p = plogis(0.2*x - 0.8) | |
y = rbinom(N, 1, p) | |
tibble(x, y) %>% | |
mutate(z = cut_number(x, 5)) %>% |
This file contains 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
// debug javscript errors with alerts | |
window.onerror = function (msg, url, lineNo, columnNo, error) { | |
var error_msg = ['msg: ' + msg, 'url: ' + url, 'lineNo: ' + lineNo, 'columnNo: ' + columnNo, 'error: ' + error].join('\n'); | |
window.alert(error_msg); | |
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.