View cars.csv
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
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 | 0 | 1 | 4 | 4 | |
Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 | 0 | 1 | 4 | 4 | |
Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.32 | 18.61 | 1 | 1 | 4 | 1 | |
Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 | |
Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.44 | 17.02 | 0 | 0 | 3 | 2 | |
Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.46 | 20.22 | 1 | 0 | 3 | 1 | |
Duster 360 | 14.3 | 8 | 360 | 245 | 3.21 | 3.57 | 15.84 | 0 | 0 | 3 | 4 | |
Merc 240D | 24.4 | 4 | 146.7 | 62 | 3.69 | 3.19 | 20 | 1 | 0 | 4 | 2 | |
Merc 230 | 22.8 | 4 | 140.8 | 95 | 3.92 | 3.15 | 22.9 | 1 | 0 | 4 | 2 |
View afile.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
This is a text file on the web |
View afile.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
This is a text file on the web" |
View put64.R
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
# Copyright 2018 Noam Ross | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all |
View dput_binary.R
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
dput_binary <- function(object, compression = "xz") { | |
encoded <- strsplit(rawToChar(serialize(memCompress(serialize(object, NULL), type = compression), NULL, ascii = TRUE)), "\n")[[1]] | |
header <- gsub(" ", "", capture.output(dput(encoded[c(1:8)]))) | |
body <- paste0("\"", paste(encoded[-c(1:8)], collapse = ""), "\"") | |
#The `gsub()` call here is to remove any whitespace or newlines introduced in | |
#printing and copy/paste | |
all <- paste0( | |
'unserialize(memDecompress(unserialize(textConnection(c(gsub("[\\\\s\\\\n]","",', |
View tar_load_version.R
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
# Requires a development branch of git2r for now. Do `remotes::install_github('ropensci/git2r@raw-blob-content')` or | |
# `renv::install('ropensci/git2r@raw-blob-content')`. This installs from source. | |
# TODO: | |
# - Add a function to extract an arbitrary file/folder, e.g., copy_git_file(path, ref, repo) | |
# - Have tar_*_version check if the target is a local file and in that case extract it and return a temporary path (turn on/off with arguments) | |
# - Guardrails and informative error messages cases such as: Not a git repository, target not present at the given reference, remote version not available. What happens with shallow clones? | |
# - Maybe only extract stuff in the `objects/` directory when needed | |
library(git2r) |
View base_r_plotting_tutorial_koontz_d-rug.r
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
### Title: Back to basics: High quality plots using base R graphics | |
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015 | |
### | |
### Date created: 20150418 | |
### Last updated: 20150423 | |
### | |
### Author: Michael Koontz | |
### Email: mikoontz@gmail.com | |
### Twitter: @michaeljkoontz | |
### |
View criticmarkup.lua
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
-- a lua filter for panodoc | |
-- run pandoc your_word_doc.docx --track-change=all -t markdown --lua-filter=criticmarkup.lua | |
-- TODO: Detect substitutions in adjacent insertion/deletions | |
-- TODO: capture whole comment hightlight rather than just start point of comment | |
function Span(elem) | |
if elem.classes[1] and elem.classes[1] == "insertion" then | |
local opener = { pandoc.RawInline(FORMAT, "{++ ") } | |
local closer = { pandoc.RawInline(FORMAT, " ++}") } | |
return opener .. elem.content .. closer | |
elseif |
View toggle-radio-layer-legends.R
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(leaflet) | |
library(tidyverse) | |
outline <- quakes[chull(quakes$long, quakes$lat),] | |
map <- leaflet(quakes) %>% | |
addTiles(group = "OSM (default)") %>% | |
# Overlay groups | |
addCircles(~long, ~lat, ~10^mag/5, stroke = F, group = "Quakes") %>% | |
addPolygons(data = outline, lng = ~long, lat = ~lat, |
View fix.csv.R
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
#' Use the data editor for a CSV file | |
#' | |
#' This function loads a CSV file, lets the user edit it in the native data | |
#' editor, then re-saves it, prompting the user for a new file name if desired. | |
#' | |
fix.csv <- function(file, new.name=TRUE, sep=",", comment.char="") { | |
tmpframe <- read.csv(file, sep=sep,quote="", colClasses="character", | |
stringsAsFactors=FALSE, comment.char="", | |
blank.lines.skip=FALSE, na.strings="") | |
tmpframe <- edit(tmpframe) |
NewerOlder