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
/*** | |
* Given a sequence of integers as an array, | |
* determine whether it is possible to obtain | |
* a strictly increasing sequence by removing | |
* no more than one element from the array. | |
* | |
* Note: sequence a0, a1, ..., an is considered | |
* to be a strictly increasing if | |
* a0 < a1 < ... < an. Sequence containing | |
* only one element is also considered to be |
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
# Source file: rcmd.ps1 | |
# | |
# A PowerShell script for batch execution of R specifically | |
# for the naijR project | |
# TODO: Affirm script execution policy | |
[CmdletBinding()] | |
PARAM ( |
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
# Intuition of the MA model based on https://www.youtube.com/watch?v=voryLhxiPzE | |
dat <- data.frame(f.hat = NA, epsilon = c(-2, 1, 0, 2, 1), f = NA) | |
mu <- 10 | |
phi <- .5 | |
for (i in seq(nrow(dat))) { | |
if (i == 1L) | |
dat$f.hat[i] <- mu |
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
install.packages("remotes") | |
remotes::install_github("BroVic/RQDAassist", ref = "apple") | |
RQDAassist::install() |
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 <vector> | |
#include <numeric> | |
#include <unordered_map> | |
#include <algorithm> | |
#include <iostream> | |
std::vector<int> solution(int N, std::vector<int> &A) { | |
// write your code in C++14 (g++ 6.2.0) | |
// for each element of the list | |
// if the element at the position is same as `max` i.e. it doesn't exist in monitor |
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
if (getRversion() < 4.1) | |
stop("R version 4.1 or greater is required", call. = FALSE) | |
dat <- mtcars | |
levs <- | |
structure( | |
.Data = list(c("V-shaped", "straight"), c("automatic", "manual")), | |
names = fcols <- c('vs', 'am') | |
) | |
for (i in fcols) | |
dat[[i]] <- (dat[[i]] == 0) |> |
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
stopifnot(getRversion() >= 4.1) | |
dat <- mtcars | |
levs <- | |
structure( | |
.Data = list(c("V-shaped", "straight"), c("automatic", "manual")), | |
names = fcols <- c('vs', 'am') | |
) | |
for (i in fcols) | |
dat[[i]] <- (dat[[i]] == 0) |> |
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
# install.packages('xlsx') | |
library(dplyr) | |
vals <- sapply(ls(pos = "package:dplyr"), function(x) { | |
if (is.function(get(x))) | |
return(TRUE) | |
FALSE | |
}) | |
funcs <- vals[vals] |
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(naijR) | |
# 1. Draw plot of North-East GPZ | |
# First, get the states of interest | |
# Then, pass them to the mapping function's `region` parameter | |
ne <- states(gpz = "ne") | |
map_ng( | |
region = ne, | |
title = "North-East Geopolitical Zone", | |
fill = TRUE, |
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(readxl) | |
library(tidyr) | |
# My Path. Use yours | |
path <- | |
"~/Documents/5-Personal/Data/DATA DHIS MONTHLY RI TEMPLATE 5.xlsx" | |
riData <- read_xlsx(path = path) | |
riData <- riData[-c(2:3),] | |
hdr <- unname(unlist(riData[1,])) |