power <- function(x, power) {
return(x^power)
}
foo <- function(x, ...) {
cat("You just called 'foo'\n")
power(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
#include <stdlib.h> | |
#include <stdio.h> | |
// samples the height of one structure for a given maximum height (H) | |
int sample_height(int maxHeight) { | |
int height = 0; | |
while (rand() % 2 == 1 & height < maxHeight) { | |
height++; | |
} | |
return height; |
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
# create some random data | |
set.seed(123) | |
x <- rpois(100, lambda = 100) | |
# approach 1: hard to compare due to different aspect ratios | |
hist(x, breaks = c((min(x) - 1):(1 + max(x)))) | |
plot(table(x), main = "Barplot of x") | |
# approach 2: easier to compare | |
library(dplyr) |
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
``` r | |
library(extrafont) | |
#> Registering fonts with R | |
# font_install('fontcm') # try this if its not working | |
suppressMessages(loadfonts()) | |
# check that the LM Roman fonts are installed with | |
"CM Roman" %in% fonts() | |
#> [1] TRUE | |
# main script ============ |
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
# set parameters for the dataset | |
possible_values <- c(1:10, 99, NA) | |
n_rows <- 1000 | |
n_cols <- 10 | |
col_names <- letters[1:n_cols] | |
# create a matrix with the sampled data, that will be transformed into a data.frame in the next step | |
mwe_matrix <- matrix(sample(possible_values, n_rows * n_cols, replace = T), | |
nrow = n_rows, ncol = n_cols) |
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
``` r | |
library(ggplot2) # data vis | |
library(dplyr) # data manipulation | |
#> | |
#> Attaching package: 'dplyr' | |
#> The following objects are masked from 'package:stats': | |
#> | |
#> filter, lag | |
#> The following objects are masked from 'package:base': | |
#> |
################################################################################
# Goal of this short script is to show the basic inner workings of the
# tidyAnimatedVerbs package.
library(tidyverse)
library(gganimate)
# load all functions from the tidyAnimatedVerbs package
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
``` r | |
library(tidyverse) | |
df <- data_frame(x = 1:3, y = c("A", "B", "C")) | |
df %>% | |
mutate( | |
new_y = case_when( | |
y == "A" ~ "Alice", | |
y == "B" ~ "Bob", |
library(imager) # for loading and plotting of the PNG file
library(glue) # for string parsing
library(png) # alternative for image loading
take_screenshot <- function(file = "screenshot.png", force_imagemagick = FALSE) {
if (Sys.info()[["sysname"]] == "Linux" &&
as.numeric(system("cat /var/log/dpkg.log | grep scrot | wc -l", intern = TRUE)) > 0 &&
!force_imagemagick) {
library(tidyverse) # for data manipulation
library(rvest) # for web scraping of the bundeswahlleiter
library(GGally) # for the correlelogram
#' Downloads the data from the Bundeswahlleiter
#'
#' @param url the url to download, used internally only as the function calls itself recursively, the url is the url for the respective page,
#' i.e., https://www.bundeswahlleiter.de/europawahlen/2019/ergebnisse/bund-99/land-2.html or
#' https://www.bundeswahlleiter.de/europawahlen/2019/ergebnisse/bund-99/land-8/kreis-8435.html
OlderNewer