Skip to content

Instantly share code, notes, and snippets.

View oousmane's full-sized avatar
🎯
Focusing

Ousmane Ouedraogo oousmane

🎯
Focusing
View GitHub Profile
@oousmane
oousmane / check_functions.R
Last active March 25, 2024 14:28
utils functions for chess
#' Title
#'
#' @param x
#'
#' @return
#' @export
#'
#' @examples
is_integer <- function(x){
@oousmane
oousmane / get_sunrisesunset.r
Created November 5, 2023 19:12
Get sunrise and sunset time for any location and date from sunsetsunrise.io API
#' Get sunrise and sunset time for any location and date from sunsetsunrise.io API
#'
#' @param lon longitude in decimal degree of the location
#' @param lat latitude in decimal degree of the location
#' @param date a date string in 'yyy-mm-dd' format.
#'
#' @return a tibble with sunset/sunrise time, day length, location timezone and date
#' @export
#'
#' @examples
Default atmospheric CO2 concentration from 1902 to 2099 (updated 01/08/2022)
Year CO2 (ppm by volume)
============================
1902 297.4
1905 298.2
1912 300.7
1915 301.3
1924 304.5
1926 305.0
1929 305.2
@oousmane
oousmane / write_fwf.R
Created May 3, 2023 11:39 — forked from haozhu233/write_fwf.R
Generate fixed width file in R
#' Generate fixed width file in R
#' @description This simple function creates fixed width file with no
#' extra dependencies.
#' @param justify "l", "r" or something like "lrl" for left, right, left.
#' @examples dt <- data.frame(a = 1:3, b = NA, c = c('a', 'b', 'c'))
#' write_fwf(dt, "test.txt", width = c(4, 4, 3))
#' @export
write_fwf = function(dt, file, width,
justify = "l", replace_na = "NA") {
fct_col = which(sapply(dt, is.factor))
@oousmane
oousmane / terra-idrisi-raster-plot.R
Last active April 8, 2023 23:45
This code provide a way to read in IDRISI Raster Format with terra and plot with ggplot2
library(terra) # Spatial Data Analysis
library(tidyterra) # 'tidyverse' Methods and 'ggplot2' Helpers for 'terra'
library(ggplot2) # For Data Visualisations Using the Grammar of Graphics
library(rgeoboundaries) # For Political Administrative Boundaries
library(ggspatial) # Spatial Data Framework for ggplot2
library(ggtext) # Improved Text Rendering Support for 'ggplot2'
library(ggsflabel) # for spatial labeling
x <- terra::rast(x = "/Volumes/OUSMANE/exo_BSD/semis_fin_07/sem0173.rst")
y <- classify(x,c(0,1,2,3,4,5,6,7,8))