Skip to content

Instantly share code, notes, and snippets.

View DeepanshKhurana's full-sized avatar
💻
Learning

Deepansh Khurana DeepanshKhurana

💻
Learning
View GitHub Profile
@DeepanshKhurana
DeepanshKhurana / functions.R
Created March 31, 2023 16:11
Reactable Multi-row Example
#' @export
#'
true_round <- function(number, digits) {
number <- as.numeric(number)
posneg <- sign(number)
number <- abs(number) * 10^digits
number <- number + 0.5 + sqrt(.Machine$double.eps)
number <- trunc(number)
number <- number / 10 ^ digits
number * posneg
@DeepanshKhurana
DeepanshKhurana / price_formatting.R
Last active March 31, 2023 15:23
Format Prices
#' @export
#'
true_round <- function(number, digits) {
number <- as.numeric(number)
posneg <- sign(number)
number <- abs(number) * 10^digits
number <- number + 0.5 + sqrt(.Machine$double.eps)
number <- trunc(number)
number <- number / 10 ^ digits
number * posneg
@DeepanshKhurana
DeepanshKhurana / app.R
Created March 25, 2023 08:43
Using Reactable with YAML
# Loading Libraries ----
library(reactable)
library(yaml)
library(shiny)
# Generate Reactable Function ----
generate_reactable <- function(data,
table_type,
@DeepanshKhurana
DeepanshKhurana / reactable_edit.R
Created March 21, 2023 06:50
editable-reactable-modal
library(shiny)
library(reactable)
library(dplyr)
ui <- fluidPage(
actionButton(inputId = "edit",
label = "Edit"),
reactableOutput("table")
)
@DeepanshKhurana
DeepanshKhurana / facebook-birthdays.py
Last active November 10, 2022 11:08
Python script to create a .csv from Facebook's Event Data to list Birthdays.
# Imports
import requests
import re
import pandas as pd
import numpy as np
# Initialising Variables
names = []
@DeepanshKhurana
DeepanshKhurana / TextRank4Keyword.py
Created April 16, 2019 08:07 — forked from BrambleXu/TextRank4Keyword.py
TextRank for Keyword Extraction
from collections import OrderedDict
import numpy as np
import spacy
from spacy.lang.en.stop_words import STOP_WORDS
nlp = spacy.load('en_core_web_sm')
class TextRank4Keyword():
"""Extract keywords from text"""
@DeepanshKhurana
DeepanshKhurana / package-install.R
Created January 17, 2019 09:41
A simple script to quickly install R packages on R and R Studio based on categories
# This script will let you choose R packages. There's a mechanism to check whether the package is already installed, and it will print a # statement with the package name if it is installed.
# This can also serve as a handy list for the
# Linux Dependencies: libssl-dev, libcurl4-openssl-dev and libxml2-dev, unixodbc-dev
wrangling <- c("tidyverse", "gsubfn", "googlesheets", "stringr", "stringi", "readr", "data.table", "lubridate")
analysis <- c("MASS", "caret", "CARS", "sqldf")
graphics <- c("ggmap", "gridExtra", "RColorBrewer", "scales", "plotly") #ggplot2 is done in tidyverse
sql <- c("RSQLite", "odbc")
@DeepanshKhurana
DeepanshKhurana / reverse-geolocate.R
Last active February 10, 2019 14:34
A simple function that uses plyr and ggmap along with the Google Maps API to fetch a dataframe of City, Location, State and Country
# @dependency ggmap for the geocode function
# @dependency plyr for ldply
#
#
# @param lat - The latitude value or column using $ notation
# @param long - The longitude value or column using $ notation
# @param api.key - Your Google Geocoding API key.
# You'll need to get one here: https://developers.google.com/maps/documentation/geocoding/start
# The Geocoding API requires you to sign up with payment details. You may get charged for using it in huge volumes.
# Please refer to the official documentation provided by Google on their pages.