Skip to content

Instantly share code, notes, and snippets.

View mkim0710's full-sized avatar

mkim0710 mkim0710

View GitHub Profile
@mick001
mick001 / neuralnetR.R
Last active November 26, 2023 19:12
A neural network exaple in R. Full article at: http://datascienceplus.com/fitting-neural-network-in-r/
# Set a seed
set.seed(500)
library(MASS)
data <- Boston
# Check that no data is missing
apply(data,2,function(x) sum(is.na(x)))
# Train-test random splitting for linear model
@gluc
gluc / Desc_JSON_to_df.md
Last active June 19, 2023 02:32
Convert a complex JSON to an R data.frame

This gist shows how to convert a nested JSON file to an R data.frame. To do this, it uses jsonlite and data.tree.

The gist contains two examples: one is a bit simpler, the second one a bit more advanced.

Example 1

In the first example, we download all the repos from Hadley Wickham's Github account from https://api.github.com/users/hadley/repos . This JSON contains a nested owner object. The code shows how to convert that in a flat data.frame in three statements:

  1. line 5: download
  2. line 8: convert to data.tree
@dgrtwo
dgrtwo / saveRDS.Rmd
Last active September 3, 2018 19:08
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)
```
@ZeccaLehn
ZeccaLehn / ExploreHiddenR.md
Last active December 1, 2020 15:23
[R] Explore Hidden Environments and Functions -- by example

Shows function Internals

library(BayesianFirstAid)
debugonce(bayes.t.test) # turns off debugging for function after first run
bayes.t.test(co2)

Returns hidden and unhidden environments

@hyeshik
hyeshik / 1226 Burger Index.ipynb.json
Last active September 1, 2022 01:36
An IPython notebook for analysis of the distributions of fast-food hamburger shops.
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "",
"signature": "sha256:f99925a6f73a1e36bc91415d84266705e3bdf72304d8dba7bcfb6c94ca7b270a"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@stephenturner
stephenturner / microbenchmark-blog-post.R
Last active July 28, 2017 19:56
Code for GGD blog post on microbenchmark
# see blog post here:
# http://gettinggeneticsdone.blogspot.com/2015/01/microbenchmark-package-r-compare-runtime-r-expressions.html
library(dplyr)
library(nycflights13)
flights
# base
aggregate(flights$arr_delay, by=list(flights$carrier), mean, na.rm=TRUE)
@bquistorff
bquistorff / Stata-syntax-highlighting-notepad++.xml
Last active March 9, 2025 07:32
Notepad++ syntax highlighting file for Stata code
<NotepadPlus>
<UserLang name="Stata" ext="do ado" udlVersion="2.1">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="2" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="yes" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00// 00* 00/// 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>

This Gist contains the script and generated output file for an Acer B276HUL.

The pre-generated file below is known to work with:

  • OS X Mavericks
  • OS X Yosemite
  • OS X El Capitan

For El Capitan:

  1. Restart your Mac while holding Command-R: this puts your Mac into Recovery Mode.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# export from R to Excel with conditional highlighting
# see http://stackoverflow.com/questions/21618556/export-data-frames-to-excel-via-xlsx-with-conditional-formatting
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# get some data from the psych package
library(psych)
dat <- bfi
# load xlsx
library(xlsx)
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten