Skip to content

Instantly share code, notes, and snippets.

View mkim0710's full-sized avatar

mkim0710 mkim0710

View GitHub Profile
@mkim0710
mkim0710 / matrix to integer.r
Last active October 19, 2018 16:45
matrix to integer.r
set.seed(1)
m = array(runif(12) * 10, c(3, 4))
class(m)
typeof(m)
dput(m)
# > class(m)
# [1] "matrix"
# > typeof(m)
# [1] "double"
@mkim0710
mkim0710 / matrix to integer -void.r
Last active October 19, 2018 16:25
matrix to integer -void.r
set.seed(1)
m = array(runif(12) * 10, c(3, 4))
dput(m)
# > dput(m)
# structure(c(2.655086631421, 3.7212389963679, 5.72853363351896,
# 9.08207789994776, 2.01681931037456, 8.98389684967697, 9.44675268605351,
# 6.60797792486846, 6.2911404389888, 0.617862704675645, 2.05974574899301,
# 1.76556752528995), .Dim = 3:4)
m2 = as.integer(m)
dput(m2)
@mkim0710
mkim0710 / onedrive-ubu.sh
Created September 15, 2018 00:29 — forked from glmdev/onedrive-ubu.sh
A bash script to setup OneDrive integration with GNOME on Ubuntu.
#!/bin/sh
# onedrive-ubu.sh
# A BASH script to set up OneDrive integration with GNOME on Ubuntu
# Copyright (C) 2018 Garrett Mills ([email protected])
# This software is licensed under the MIT License.
# This sofware is provided without warranty or even any implied intent of purpose.
#
# OnedriveD: https://github.com/xybu/onedrived-dev
#
@mkim0710
mkim0710 / saveRDS.Rmd
Created September 3, 2018 19:08 — forked from dgrtwo/saveRDS.Rmd
saveRDS speed and size
---
title: "Effect of compression type and file complexity on saveRDS size and speed"
author: "David Robinson"
date: "April 20, 2015"
output: html_document
---
```{r echo = FALSE}
knitr::opts_chunk$set(cache = TRUE, message = FALSE)
```
# 셀레늄 패키지와 rvest 패키지를 설치합니다.
source("https://install-github.me/ropensci/RSelenium")
install.packages("rvest")
install.packages("dplyr")
# 패키지를 불러서 사용할 준비를 합니다.
library(RSelenium)
library(rvest)
library(dplyr)
@mkim0710
mkim0710 / ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34.rowMeansReverseCoded.na.omit from .r
Created July 29, 2018 16:47
ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34.rowMeansReverseCoded.na.omit from .r
ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34 %>% mutate(
Q3138rowMeansReverseCoded = as.numeric(Q31 + 6 - Q32 + Q33 + 6 - Q34 + Q35 + Q36 + 6 - Q37 + 6 - Q38)/8 # remove labels
, Q3138rowSumsReverseCoded = as.numeric(Q31 + 6 - Q32 + Q33 + 6 - Q34 + Q35 + Q36 + 6 - Q37 + 6 - Q38) # remove labels
) %>% select(Q31, Q32, Q33, Q34, Q35, Q36, Q37, Q38, matches("Q3138"))
# > ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34 %>% mutate(
# + Q3138rowMeansReverseCoded = as.numeric(Q31 + 6 - Q32 + Q33 + 6 - Q34 + Q35 + Q36 + 6 - Q37 + 6 - Q38)/8 # remove labels
# + , Q3138rowSumsReverseCoded = as.numeric(Q31 + 6 - Q32 + Q33 + 6 - Q34 + Q35 + Q36 + 6 - Q37 + 6 - Q38) # remove labels
# + ) %>% select(Q31, Q32, Q33, Q34, Q35, Q36, Q37, Q38, matches("Q3138"))
# # A tibble: 191 x 10
@mkim0710
mkim0710 / ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34.rowMeans.na.omit from .r
Created July 28, 2018 20:32
ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34.rowMeans.na.omit from .r
ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34 %>% mutate(
Q3138rowMeans = rowMeans(.[, c("Q31", "Q32", "Q33", "Q34", "Q35", "Q36", "Q37", "Q38")], na.rm = T)
, Q3138rowSums = rowSums(.[, c("Q31", "Q32", "Q33", "Q34", "Q35", "Q36", "Q37", "Q38")], na.rm = T)
, Q4044rowMeans = rowMeans(.[, c("Q40", "Q41", "Q42", "Q43", "Q44")], na.rm = T)
, Q4044rowSums = rowSums(.[, c("Q40", "Q41", "Q42", "Q43", "Q44")], na.rm = T)
) %>% select(Q31, Q32, Q33, Q34, Q35, Q36, Q37, Q38, matches("Q3138"), Q40, Q41, Q42, Q43, Q44, matches("Q4044")) %>%
# > ID_207_Group_Project_Version_2_Vertical_July_24_2018_07_34 %>% mutate(
# + Q3138rowMeans = rowMeans(.[, c("Q31", "Q32", "Q33", "Q34", "Q35", "Q36", "Q37", "Q38")], na.rm = T)
# + , Q3138rowSums = rowSums(.[, c("Q31", "Q32", "Q33", "Q34", "Q35", "Q36", "Q37", "Q38")], na.rm = T)
--#@@ [Research] HCCI MDD annual prevalence 180501.pptm -p128.sql ----
select count(z_patid), count(distinct z_patid)
from hcci.MEMBER_SDDV2_1115
where (
z_patid in (
select z_patid
from hcci.MEMBER_SDDV2_1115
where (
gdr in ('1', '2')
#@ function.11matching.by.factors() -----
function.11matching.by.factors = function(data, varname4MatchingUpon = "diabetes", varnames4MatchingBy = c("age", "sex"), seed = 1) {
library(tidyverse)
if ("RowNum_original" %in% names(data)) {
warning('"RowNum_original" %in% names(data)')
} else {
data$RowNum_original = 1:nrow(data)
}
set.seed(seed)
data$runif = runif(nrow(data))
@mkim0710
mkim0710 / MWEblogpost.Rmd
Created May 19, 2018 16:07 — forked from jknowles/MWEblogpost.Rmd
R Markdown of blog post on R minimal working examples (MWE).
How to Ask for Help using R
========================================================
The key to getting good help with an R problem is to provide a minimally working
reproducible example (MWRE). Making an MWRE is really easy with R, and it will
help ensure that those helping you can identify the source of the error, and
ideally submit to you back the corrected code to fix the error instead of sending
you hunting for code that works. To have an MWRE you need the following items:
- a minimal dataset that produces the error