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
library(dplyr) | |
library(ggplot2) | |
library(lubridate) | |
library(COVID19) | |
covid <- covid19() | |
cases_deaths <- covid %>% | |
filter(iso_alpha_3 %in% c("AUT", "BEL", "BGR", "HRV", |
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
--- | |
title: "Results of example survey" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = FALSE) | |
#rmarkdown::render("test.Rmd") | |
``` |
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
Random question? | Copy of Random question? | Copy of Copy of Random question? | Copy of Copy of Copy of Random question? | |
---|---|---|---|---|
no | yes | yes | yes | |
yes | yes | no | yes | |
yes | no | no | no | |
yes | yes | yes | yes | |
no | no | yes | yes | |
yes | no | no | ||
no | yes | no | no | |
yes | yes | |||
no | yes | no | no |
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
library(tidyverse) | |
# from https://skill-lync.com/student-projects/week-4-genetic-algorithm-295 | |
# maximum is at x = 0.0663 y = 0.0673 f = 1 | |
stalagmite <- function(x, y){ | |
f1_x <- (sin(5.1*pi*x + 0.5))^6 | |
f1_y <- (sin(5.1*pi*y + 0.5))^6 | |
f2_x <- exp((-4*log(2))*((x-0.0667)^2)/0.64) |
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
library(broom) | |
library(purrr) | |
library(dplyr) | |
library(ggplot2) | |
run_spurious_regression <- function(nvars = 6, nobs = 1000){ | |
dataset <- as.data.frame(replicate(nvars, rnorm(nobs))) | |
tidy(lm(V1 ~ ., data = dataset)) | |
} |
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
#script to video https://youtu.be/bNh2WDdRleI | |
library(tidyverse) | |
# from https://skill-lync.com/student-projects/week-4-genetic-algorithm-295 | |
# maximum is at x = 0.0663 y = 0.0673 f = 1 | |
stalagmite <- function(x, y){ | |
f1_x <- (sin(5.1*pi*x + 0.5))^6 | |
f1_y <- (sin(5.1*pi*y + 0.5))^6 |
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
# Script to the video: https://youtu.be/erlWsquoHlM | |
set.seed(1234) | |
x <- abs(rnorm(1000)) | |
in_base_R <- `^`(x, 2) | |
# code from https://helloacm.com/exponentiation-by-squaring/ |
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
#code to the video: https://youtu.be/hs7q64diU_c | |
library(tidyverse) | |
# prepare johnson df | |
data(JohnsonJohnson) | |
johnson <- as_tibble(matrix(JohnsonJohnson, ncol = 4, nrow= 21, byrow = TRUE)) %>% | |
rename(quarter1 = V1, | |
quarter2 = V2, |
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
--- | |
date: 2021-04-17 | |
title: Dealing with non-representative samples with post-stratification | |
tags: [R] | |
menu: | |
main: | |
parent: Blog | |
identifier: /blog/post_strat | |
weight: 1 | |
--- |
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
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Layer configuration: | |
This function should only modify configuration layer settings." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory | |
;; `+distribution'. For now available distributions are `spacemacs-base' |