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
from datetime import datetime, timedelta | |
from airflow.utils.dates import days_ago | |
from airflow import DAG | |
from airflow.providers.docker.operators.docker import DockerOperator | |
from airflow.operators.python import PythonOperator | |
from docker.types import Mount | |
import os |
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
version: "3.9" | |
services: | |
rstudio: | |
image: "rkrispin/atsaf:dev.0.0.0.9000" | |
ports: | |
- "8787:8787" | |
volumes: | |
- type: "bind" | |
source: "$ATSAF_DIR" | |
target: "/home/rstudio" |
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
# Forecasting Sandbox ---- | |
# This is an example for a Shinylive R app | |
# The app provides a forecasting sandbox for the AirPassengers dataset | |
# It supports 3 stats forecasting models - Linear Regression, ARIMA, and Holt-Winters | |
library(shiny) | |
data(AirPassengers) | |
# UI ---- | |
ui <- fluidPage( |
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
#!/bin/bash | |
# Launching RStuido server on a docker with different settings | |
# Basic run command to launce rocker container with RStudio Server | |
docker run -d -p 8787:8787 \ | |
-e USER=rstudio -e PASSWORD=rstudio \ | |
rocker/rstudio:4.2 | |
# Disabling the authentication |
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
# Print messages with print and cat | |
print("This is the message I want to print") | |
cat("This is the message I want to print\n") # Using the \n operator to jump for the next line | |
# The print command can also print code output | |
print(data.frame(x = 1:3, y = 4:6)) | |
# Where cat cannot print non text or multiple vector objects | |
cat(data.frame(x = 1:3, y = 4:6)) | |
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
#generate random numbers | |
set.seed(1234) | |
x1 <- rnorm(n = 1000, mean = 3, sd = 3) | |
x2 <- rnorm(n = 1000, mean = 0, sd = 1) | |
noise <- runif(n = 1000, min = 0, max = 1) | |
# Set formula | |
y <- 5 * x1 - 3 * x2 + noise | |
# Run regression |
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
# Adding regression line to a plot | |
set.seed(1234) | |
# Creating a random dataset | |
x <- rnorm(n = 1000, mean = 10, sd = 3) | |
y <- 2 * x + 10 + rnorm(n = 1000, mean = 0, sd = 4) | |
d <- data.frame(y = y, | |
x = 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
library(plotly) | |
df <- data.frame(y = c(21, 44, 27, 8), | |
x = c(100, 200, 150, 250)) | |
df$x_cum <- cumsum(df$x) | |
df$y_cum <- cumsum(df$y) | |
df |
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
# Plotting COVID19 daily new cases in the Ghana | |
# Using the following libraries: | |
# coronavirus for data | |
# plotly for dataviz | |
# dplyr for data manipulation | |
library(coronavirus) | |
library(plotly) | |
library(dplyr) | |
df <- refresh_coronavirus_jhu() |
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
# Plotting COVID19 daily new cases in the US | |
# Using the following libraries: | |
# coronavirus for data | |
# plotly for dataviz | |
# dplyr for data manipulation | |
library(coronavirus) | |
library(plotly) | |
library(dplyr) | |
df <- refresh_coronavirus_jhu() |
NewerOlder