Skip to content

Instantly share code, notes, and snippets.

Avatar

Kar kar9222

View GitHub Profile
@kar9222
kar9222 / vim_useful_tricks.md
Last active Apr 26, 2021
Vim - Useful tricks
View vim_useful_tricks.md
@kar9222
kar9222 / httpgd.md
Last active Apr 10, 2021
SVG graphic device in external browser
View httpgd.md
@kar9222
kar9222 / pfizer_vaccine_effectiveness_simulation.md
Last active Dec 31, 2020
Pfizer's vaccine effectiveness simulation
View pfizer_vaccine_effectiveness_simulation.md

Pfizer's vaccine effectiveness simulation

Just for fun 😄. I saw this post about Pfizer's Vaccine Effectiveness Simulation. So I simply translate the Bayesian model (implemented in Stan) into my favorite Julia library Turing.jl. For details, please read the link.

Very briefly, from Vaccine Effectiveness Simulation

NYT reports a 44 thousand person trial with half of the people going to treatment and half to control. They further report that 162 people developed COVID in the control group and 8 where in the vaccine group. What is the probability that the vaccine is effective and what is the uncertainty in that probability? The Pfizer protocol defines vaccine effectiveness as follows:

equation

@kar9222
kar9222 / custom_{skimr}_summary_stats.md
Last active Dec 4, 2020
Custom {skimr} summary stats
View custom_{skimr}_summary_stats.md

Custom {skimr} summary stats

Just discovered a nice little custom {skimr} summary stats by rOpenSci. I use it mainly in the R console for quick summary

  • different summary stats for different classes
  • distribution (unicode)
  • head & tail of raw data
  • easily customizable

Initial draft. Use at your own risk. Feel free to use it at your interactive package, .Rprofile, etc

  • Name the functions as you like e.g. su stands for summary
@kar9222
kar9222 / linear_model_foundation_of_architecture_of_deep_learning.md
Last active Jul 24, 2020
Linear model, the foundation of architecture of deep learning
View i_love_base_R.md

I dont use base R for everything. But I use & ❤️ base R

  • Super high emphasis on stability & backward compatibility
  • No dependency
  • Works well with {data.table}
  • Most importantly, it's the foundation of all packages

Feel free to see image & shared Gist link. You might find some useful ones.

Imgur

@kar9222
kar9222 / fst_and_data.table.md
Last active Dec 4, 2020
{fst} + {data.table}
View fst_and_data.table.md

{data.table} + {fst}

For medium (not big) data with RAM issues, for native R solutions, I often use {fst} + {data.table}. Keys are

  • load only needed data in RAM
  • during data wrangling, whenever possible, do NOT shallow/deep copy objects. Use 'reference semantics' e.g. {data.table} to modify in-place

Quote from Lightning fast serialization of data frames using the fst package

For a few years now, solid state disks (SSD’s) have been getting larger in capacity, faster and much cheaper. It’s not uncommon to find a high-performance SSD with speeds of up to multiple GB/s in a medium-end laptop. At the same time, the number of cores per CPU keeps growing. The combination of these two trends are opening up the way for data science to work on large data sets using a very modest computer setup.

View my_{colorout}.md

My {colorout}

First of all, thank you jalvesaq for the great package! 🙏🙏

If you'd like to colorize R terminal output you can use {jalvesaq/colorout}

I customize extra color patterns for

@kar9222
kar9222 / join_update_setkey.md
Last active Jul 4, 2020
data.table `join + update-by-reference + setkey`
View join_update_setkey.md

data.table join + update-by-reference + setkey

A basic/naive test

  • Found gem about join + update-by-reference from Left join using data.table
  • Saw a tweet reply by Michael chirico about using setkey during join
  • Combine them together

"I want to do fast & memory efficient joins but I don't want to read the performance benchmark...". You can skip to Keyfindings & Examples sections below.

Related Twitter link