Skip to content

Instantly share code, notes, and snippets.

View atet's full-sized avatar

Athit Kao atet

View GitHub Profile
@atet
atet / gist:d0a2c68ff0558c8b06181e52b8e01e11
Created August 27, 2023 23:18
Automatically download R packages.
packages_ls = c("data.table","pbapply","httr","jsonlite","stringr")
for(package in packages_ls){
if(!require(package, character.only = TRUE)){
cat("+ Installing ", package, "\n")
install.packages(package)
}
cat("+ Loading ", package, "\n")
library(package, character.only = TRUE)
}
@atet
atet / Nvidia_20201210_CNNs_101
Last active December 10, 2020 18:11
Nvidia 20201210 CNNs 101
Nvidia presentation for Thursday, 12/10/2020 workshop.
Demo files available at: https://ngc.nvidia.com/catalog/collections
NOTE: This is public content created by Nvidia and does not contain proprietary information.
# For aag123, HTH - atet
# INITIAL DATA
alldata_ls = list(list(1, 2, 3), list(4, 5, 6), list(7, 8, 9))
# INNER FUNCTION
FUN_INNER = function(x){
# DO SOMETHING
return(x)
}
# For aag123, HTH - atet
original_ls = list(
"params1" = c("a","b","c"),
"params2" = c("x","y","z")
)
str(original_ls)
# Lookup for each index
@atet
atet / combination_lapply.R
Created March 6, 2020 06:33
Combination lapply
# For aag123, HTH - atet
reads_vc = c( 10, 20, 30)
rnain_vc = c(1000, 2000, 3000)
# 1. Make new list to store all combinations
combination_ls = list()
# 2. Make all combinations first
for(i in 1:length(reads_vc)){
# R Ladies Hackathon 20200228
# Hello all, we were commenting on getting the raw data from https://data.edd.ca.gov, the fastest way I found was:
#
# 1. Register for a free API token (can only make a limited number of requests without one): https://opendata.socrata.com/login
# 2. Search for a specific dataset on https://data.edd.ca.gov/browse, e.g. "Current Employment Statistics (CES)"
# 3. Select your dataset from the results then click on the top-right "API" button to show the link to the "API endpoint" (leave default as JSON)
# 4. Install package "RSocrata": https://cran.r-project.org/web/packages/RSocrata/RSocrata.pdf
# 5. Example download JSON as data.frame:
# install.packages("RSocrata")
# For aag123, HTH - atet
# install.packages('gtools')
library(gtools)
# Number of permutations with replacement = alphabet^length
set.seed(1)
alphabet = c("A","T","C","G")
n_start = 2
n_end = 4
n_trials = 100