Skip to content

Instantly share code, notes, and snippets.

View BroVic's full-sized avatar
🎯
Focusing

Victor Ordu BroVic

🎯
Focusing
View GitHub Profile
@BroVic
BroVic / rcmd.ps1
Created September 11, 2022 10:31
A PowerShell script for automating R CMD ... for the naijR package
# Source file: rcmd.ps1
#
# A PowerShell script for batch execution of R specifically
# for the naijR project
# TODO: Affirm script execution policy
[CmdletBinding()]
PARAM (
@BroVic
BroVic / almostIncreasingSequence.cpp
Last active October 23, 2022 07:09
almostIncreasingSequence
/***
* 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
/**
After becoming famous, the CodeBots decided to move into a new
uilding together. Each of the rooms has a different cost, and
ome of them are free, but there's a rumour that all the free
ooms are haunted! Since the CodeBots are quite superstitious,
hey refuse to stay in any of the free rooms, or any of the
ooms below any of the free rooms.
Given matrix, a rectangular matrix of integers, where each
alue represents the cost of the room, your task is to return
@BroVic
BroVic / commonCharacterCount.cpp
Last active December 7, 2022 08:54
CodeSignal #4
#include <string>
#include <iostream>
#include <map>
#include <utility>
using namespace std;
int solution(string s1, string s2)
{
@BroVic
BroVic / install-r413.ps1
Created December 9, 2022 16:47
Install R 4.1.3, R Studio and Rtools40 in one go
# install-r-suite.ps1
# (c) 2021-2022 Victor Ordu / DevSolutions Ltd. All rights reserved.
<#
.SYNOPSIS
A PowerShell script to enable the download and installation of R 4.1.3, R Studio and Rtools40.
.DESCRIPTION
This script will do the following:
1. Check whether R is installed on the system already.
@BroVic
BroVic / rcmd-pkg.ps1
Created January 12, 2023 16:10
A PowerShell script for controlling various actions relating to the RQDAassist project
<#
.SYNOPSIS
Control various actions to be taken on the RQDAassist repository/package.
.DESCRIPTION
The RQDAassist package repository in more complicated that some regular CRAN-compatible packages.
For instance, the RQDA packages and its dependencies have to be regularly cleaned up for tests
to be carried out on both binary and source installation options. Also, at this point, the package
is only working with R versions lower than 4.2. So when developing, one has to always remember to
use that version, when it's not the one pointed to by PATH. This script makes it easy to carry out
@BroVic
BroVic / euler.R
Created February 6, 2023 20:13
Realization of Euler's number
euler <- function(x) (1 + 1/x)^x
n <- c(1:10, 100, 1e3, 1e6, 1e9)
euler(n)
@BroVic
BroVic / autocheck.ps1
Last active February 20, 2023 14:08
PowerShell script to automate common local actions taken during maintenance of the {RQDAassist} package
<#
.SYNOPSIS
Control various actions to be taken on the RQDAassist repository/package.
.DESCRIPTION
The RQDAassist package repository is more complicated than some regular CRAN-compatible packages.
For instance, the RQDA packages and its dependencies have to be regularly cleaned up for testing
out both binary and source installation options. Also, at this point, the package
is only working with R versions lower than 4.2. So when developing, one has to always remember to
use that version, when it's not the one pointed to by PATH. This script makes it easy to carry out
@BroVic
BroVic / tmap.R
Created March 6, 2023 17:06
Integrating `naijR::map_ng` with `tmap`
library(sf)
library(tmap)
# The output of `map_ng` is of class `map` is convertible
# to an object of class `sf`
ng_map <- naijR::map_ng(plot = FALSE)
ng_sf <- st_as_sfc(ng_map)
tm_shape(ng_sf) +
tm_polygons()
@BroVic
BroVic / matrixmanip.R
Created July 6, 2023 17:14
Playing around with R matrices
(m = matrix(1:10, nrow = 5, byrow = TRUE))
m[[2]]
m[[7]]
m[[10]] <- 11L
rbind(m, c(11,12))
# Add names
i <- 0L
dimnames(m) <- lapply(c("x", "y"), function(d) {