Skip to content

Instantly share code, notes, and snippets.

View shanmdphd's full-sized avatar
🎤
share for life

Sungpil Han shanmdphd

🎤
share for life
View GitHub Profile
@shanmdphd
shanmdphd / MRE-dose-tblNCA.R
Last active February 17, 2023 16:17
Minimal reproducible example: proper input of the `dose` argument in tblNCA function in NonCompart R package
library(dplyr)
library(NonCompart)
tblNCA(Theoph,
dose = Theoph %>%
mutate(actual_dose = Wt*Dose) %>%
select(Subject, actual_dose) %>%
unique() %>%
.$actual_dose)

Keybase proof

I hereby claim:

  • I am pagk2006 on github.
  • I am pipetcpt (https://keybase.io/pipetcpt) on keybase.
  • I have a public key ASAuVUAseKg_wqpkEYmwGvXzAKyHVr_QPF3Hy6DioD5xzAo

To claim this, I am signing this object:

library(tidyverse)
tibble(estimate = c(0.23, 0.52, 0.20, 0.03, 0.45, 0.05),
rse = c(55.9, 41.4, 45.1, 19.9, 46.6, 25.5)) %>%
mutate(lower_ci = estimate - 1.96 * rse/100 * estimate) %>%
mutate(upper_ci = estimate + 1.96 * rse/100 * estimate) %>%
mutate(ci = sprintf('%0.2f - %0.2f', round(lower_ci, 2), round(upper_ci, 2)))
# A tibble: 6 x 5
estimate rse lower_ci upper_ci ci
<dbl> <dbl> <dbl> <dbl> <chr>
@shanmdphd
shanmdphd / ggforce-multiple-page.R
Created March 5, 2019 00:19
ggforce 패키지를 사용해서 여러 페이지가 있는 PDF 파일 만들기.
library(tidyverse)
library(ggforce)
# 함수 정의 ----
plot_multiple <- function(page_num) {
Theoph %>%
ggplot(aes(Time, conc)) +
geom_point() +
geom_line(alpha = 0.1) +
@shanmdphd
shanmdphd / ncaRule.R
Created September 11, 2017 23:14
ncaRule.R nca 규칙에 대한 것입니다.
# File should have the following columns
# SUBJ : Subject ID, any data type
# TRT: "R" or "T"
# GRP: "RT" or "TR"
# PRD: 1 or 2
# AUClast: numeric data type
# Cmax: numeric data type
# Tmax: numeric data type
# Other columns as you wish
@shanmdphd
shanmdphd / flatgs.sh
Last active September 11, 2017 05:33
Flatten PDFs with ghostscript (GS를 사용해서 PDF를 flattening할 수 있습니다. MacOS Sierra에서 테스트하였습니다.)
# http://zeroset.mnim.org/2015/01/07/flatten-pdfs-with-ghostscript/
# https://unix.stackexchange.com/questions/162922/is-there-a-way-to-flatten-a-pdf-image-from-the-command-line
# There should be `flat` sub-directory.
for file in *.pdf; do
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite \
-sColorConversionStrategy=/LeaveColorUnchanged \
-dAutoFilterColorImages=true \
-dAutoFilterGrayImages=true \
@shanmdphd
shanmdphd / fastBib.R
Last active September 8, 2017 02:46
Fast Bibliography Generation in R
knitr::write_bib(c('caffsim', 'NonCompart', 'ncar'), 'temp.bib')
capture.output(bibtex::read.bib('temp.bib'), file = 'temp.txt')
myBib <- readLines('temp.txt')
myBib[myBib == ''] <- '\n\n'
paste(gsub('_', '',myBib), collapse = '')
@shanmdphd
shanmdphd / my-reporters-setting.R
Created September 5, 2017 14:52
My favorite reporters setting
library(ReporteRs)
options('ReporteRs-fontsize' = 10)
potsub <- function(char) pot(char, textProperties(vertical.align = 'subscript'))
potsuper <- function(char) pot(char, textProperties(vertical.align = 'superscript'))
flexThis <- function(df){
df %>%
FlexTable(header.columns = TRUE) %>%
setFlexTableBorders(inner.vertical = mystyle$no, inner.horizontal = mystyle$std,
outer.vertical = mystyle$no, outer.horizontal = mystyle$big)

Keybase proof

I hereby claim:

  • I am shanmdphd on github.
  • I am shanmdphd (https://keybase.io/shanmdphd) on keybase.
  • I have a public key whose fingerprint is B2DD 7A5A 439E 134B 1624 16B9 D13C BC36 7863 82BC

To claim this, I am signing this object:

@shanmdphd
shanmdphd / Scatter.md
Last active October 13, 2016 07:08
NONMEM accessaries

Scatter plot matrices (pairs plots)