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 / epc.R
Last active December 1, 2023 20:21
Parse a vector of Electronic Product Codes (EPCs)
# Receives as input a vector containing EPC strings and returns a data frame
# with each component of a string assigned to the appropriate column of the
# data frame, and the data frame will have as many rows as there are strings.
parseEPC <- function(epc) {
# internal functions
## Creates a regex anchor for the beginning of a string
rgxify <- function(x) {
stopifnot(exprs = {
is.character(x)
length(x) == 1L
@BroVic
BroVic / build.ps1
Last active August 31, 2023 11:31 — forked from dmode/build.ps1
Powershell script to convert a markdown file into an word document by using pandoc
<#
.SYNOPSIS
Script to convert markdown file to word document
.DESCRIPTION
Convertes a markdown file into an word document using pandoc as converter. The process uses a word template file
.PARAMETER i
Specifies the input file. This is the markdown file
.PARAMETER o
Specifies the output file. This is the word document
.PARAMETER t
@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) {
@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 / 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 / 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 / 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 / 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 / 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)
{
/**
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