Skip to content

Instantly share code, notes, and snippets.

@MyKo101
MyKo101 / Load_Rprofile_shortcut
Created September 2, 2021 20:48
Reload Rprofile shortcut
#' Reload .Rprofile
#'
#' Re-run the .Rprofile file
#'
#' @interactive
#' @shortcut Ctrl + Shift + P
function(){
source(".Rprofile")
cat("Reloading .Rprofile\n")
}
@MyKo101
MyKo101 / scale_colour_hb.R
Created September 9, 2021 21:55
colour ggplot with hue & brightness
# Define a character to act as seperator between the two variables to be used
hb_sep <- function(x=NULL){
if(is.null(x)){
getOption("hb_sep")
} else {
options(hb_sep = x)
}
}
# Combines the hue & brightness
@MyKo101
MyKo101 / isPrime.R
Created November 9, 2022 20:25
Function to calculate whether a vector is prime.
# This function will calculate whether a vector is prime. It is not completely efficient, but it's not too bad
isPrime <- function(n){
# Check inputs are integers, and coerce
if(any(n %% 1 >0)) stop("Input must be all integers")
n2 <- as.integer(n)
# Create default output
out <- rep(NA,length(n2))
# Check for already discovered primes & return early if possible
@MyKo101
MyKo101 / diptest.py
Created July 7, 2023 12:09
Multi-Modality Testing
import itertools
from dataclasses import dataclass
from typing import Tuple
import numpy as np
from diptest import diptest
MEAN = 18.75
STDDEV = 5.647