In about:config set dfjs.disableFontFace to true
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
| # ============================================================================= | |
| # Epicycles: a Fourier curve-fitting toy for scientific epistemology | |
| # ============================================================================= | |
| # | |
| # Ptolemy's geocentric model used epicycles — circles on circles — to predict | |
| # planetary motion. It worked remarkably well. The reason is that epicycles | |
| # are mathematically equivalent to a Fourier series: any smooth periodic | |
| # function can be approximated arbitrarily well by sums of circular motions. | |
| # Ptolemy was doing harmonic analysis without knowing it. | |
| # |
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
| # ============================================================================= | |
| # Laplace's Demon and the Quantisation Problem | |
| # ============================================================================= | |
| # Laplace's demon is a thought experiment: a intelligence that knows the exact | |
| # position and momentum of every particle in the universe could, in principle, | |
| # predict its entire future. This script demonstrates why that fails. | |
| # | |
| # Any representation of a continuous value must truncate at some precision. | |
| # In a chaotic system, that irreducible truncation — however small — is the | |
| # foothold through which sensitive dependence enters. The demon's prediction |
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
| ################################################################################ | |
| # Using the US CDC life tables for White Males (2020), I wanted to estimate the | |
| # Probability that if Joe Biden or Donald Trump became the next US president | |
| # They would die in office. The general approach could be used for any interval. | |
| # The life tables can be found here: https://stacks.cdc.gov/view/cdc/118055 | |
| ################################################################################ | |
| library(tidyverse) | |
| library(lubridate) |
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
| version_new <- list.files('~/R/x86_64-pc-linux-gnu-library/4.2') | |
| version_old <- list.files('~/R/x86_64-pc-linux-gnu-library/4.1') | |
| target <- version_old[!(version_old %in% version_new)] | |
| install.packages(target) |
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
| #' In a dataframe, find all variable names that match var_pattern | |
| #' | |
| #' @param var_pattern a character string ("pattern" to match) | |
| #' @param dframe a dataframe | |
| #' | |
| #' @return all variable names in the dataframe that match var_pattern | |
| #' @export | |
| #' | |
| #' @examples | |
| #' find_var(iris, "idth") |
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
| # A quick visual analysis of Donald Trump's BMI assuming that his reported weight | |
| # in 2018 and 2019 are correct, and his real height lies between his claimed | |
| # height of 6'3" (1.9m) and a more likely height of 6'1" (1.854m) | |
| # https://www.theguardian.com/us-news/2018/jan/17/a-tall-tale-accuracy-of-trumps-medical-report-and-new-height-questioned | |
| # Include the ggplot library | |
| library(ggplot2) | |
| # Function to calculate BMI from height (m) and mass/weight (Kg) | |
| bmicalc <- function(height, mass){ |
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
| phred <- function(q){ | |
| 10^(-q/10) | |
| } | |
| inv_phred <- function(p){ | |
| 10 * log10(p) | |
| } |
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
| # These data appeared in a graph on climate.gov: http://bit.ly/2AFNBJz. | |
| # Paraphrasing from the website: | |
| # The data are for each November since 1979 to 2017. | |
| # The variable 'area' represents the combined November sea ice | |
| # area for the Chukchi and Beaufort Seas, the two sub-basins of | |
| # the Arctic Ocean that touch Alaska’s Arctic (northern) coast. | |
| # Larger values means more sea ice in the combined basin in square kilometres. | |
| # The variable 'temp' is the November temperature (Fahrenheit) at Utqiaġvik, | |
| # also known as Barrow (71°17′26″N 156°47′19″W). | |
| # The data were digitised using Plot Digitizer |
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
| # This is a quick script to create two time series plots using World Bank data downloaded using the wbstats package | |
| # and plotted using ggplot2. | |
| # The first plot uses Malaysia data only, and is a time series plot showing Life Expectancy at Birth changes | |
| # in the whole population and for males and females separately. | |
| # The second plot uses data for a handful of Southeast Asian countries and Australia and shows changes in the | |
| # Infant Mortality Rate over time. | |
| library(wbstats) | |
| library(tidyverse) |
NewerOlder