This is merely a suggestion.
- the R SVG logo with the function code for help() overlayed (not all of it).
| ## load the data.table package | |
| library(data.table) | |
| ## make this reproducible (up to memory locations) | |
| set.seed(123) | |
| ## create a data.table with some dummy data | |
| DT1 <- data.table(x=1:5, y=runif(5)) | |
| DT1 | |
| # x y |
| ## load the usual packages | |
| library(magrittr) | |
| library(dplyr) | |
| library(ggplot2) | |
| ## install and load the likert package from GitHub | |
| # devtools::install_github('jbryer/likert') | |
| library(likert) | |
| ## load the data downloaded from the survey |
| tmp <- data.frame(a = c(1, 2, 3), b = c(4, 3, 5), c = c(4, 4, 5)) | |
| tmp | |
| # a b c | |
| # 1 1 4 4 | |
| # 2 2 3 4 | |
| # 3 3 5 5 | |
| formula(tmp) | |
| # a ~ b + c |
| #' Replace categorical x-axis labels with images | |
| #' | |
| #' Pipe a ggplot2 graph (with categorical x-axis) into this function with the argument of a list of | |
| #' pictures (e.g. loaded via readImage) and it builds a new grob with the x-axis categories | |
| #' now labelled by the images. Solves a problem that you perhaps shouldn't have. | |
| #' | |
| #' @author J. Carroll, \email{jono@@jcarroll.com.au} | |
| #' @references \url{http://stackoverflow.com/questions/29939447/icons-as-x-axis-labels-in-r-ggplot2} | |
| #' | |
| #' @param g ggplot graph with categorical x axis |
| library(rvest) | |
| ## GDP per capita, top 10 countries | |
| url <- "https://en.wikipedia.org/wiki/List_of_countries_by_GDP_(nominal)_per_capita" | |
| html <- read_html(url) | |
| gdppc <- html_table(html_nodes(html, "table")[3])[[1]][1:10,] | |
| ## clean up; remove non-ASCII and perform type conversions | |
| gdppc$Country <- gsub("Â ", "", gdppc$Country) | |
| gdppc$Rank <- iconv(gdppc$Rank, "latin1", "ASCII", sub="") |
| library(ggplot2) ## devtools::install_github("hadley/ggplot2) | |
| library(grid) ## rasterGrob | |
| library(EBImage) ## readImage (alternatively: magick::image_read) | |
| library(ggthemes) ## theme_minimal | |
| ## ########## | |
| ## INDEPENDENT CODE TO BE SOURCED: | |
| ## ########## | |
| # user-level interface to the element grob |
| ## Based on BUILDING A GGPLOT2 STEP BY STEP | |
| ## https://matthewdharris.com/2016/08/12/ggplot2-step-by-step/ | |
| ## 'reproducible' saving of data: | |
| ## this was to be copied by hand, hoping that Unicode chars didn't get caught up | |
| ## requires re-formatting to factors, etc... | |
| year <- c(1760, 1790, 1797, 1850, 1860, 1889, 1900, 1910, 1950) | |
| sites <- c("Isleta", "Acoma", "Laguna", "Zuni", "Sandia", "San Felipe", | |
| "Santa Ana", "Zia", "Santo Domingo", "Jemez", "Cochiti", | |
| "Tesuque", "Nambe", "San Ildefonso", "Pojoaque", "Santa Clara", |
This is merely a suggestion.
| ## Process the Stack Overflow Answers data for my own account | |
| ## jonathan-carroll -- 4168169 | |
| ## | |
| ## Jonathan Carroll | |
| ## 21 October, 2016 | |
| ## | |
| ## https://twitter.com/carroll_jono/status/789319774773714946 | |
| ## load required packages | |
| library(dplyr) |
| library(dplyr) | |
| library(ggplot2) | |
| find_functions <- function(file) { | |
| getParseData(parse(file = file)) %>% | |
| filter(token == "SYMBOL_FUNCTION_CALL") %>% | |
| distinct(text) %>% | |
| use_series(text) | |
| } |