Skip to content

Instantly share code, notes, and snippets.

View mkim0710's full-sized avatar

mkim0710 mkim0710

View GitHub Profile
@kevinushey
kevinushey / RcppMelt.md
Last active August 2, 2016 03:13
Implementing reshape2::melt in Rcpp.

Melting with Rcpp

A common data manipulation task is that of making 'wide' data 'long': for example, using the reshape2 library,

library(reshape2)
wide_df <- data.frame( stringsAsFactors=FALSE,
@SalGnt
SalGnt / force-rgb-mode-in-mac-os-x-to-fix-the-picture-quality-of-an-external-monitor.md
Last active July 5, 2023 19:30
Force RGB mode in Mac OS X to fix the picture quality of an external monitor.

Force RGB mode in Mac OS X to fix the picture quality of an external monitor (Original)

Update: I have heard that 10.8.3 has solved this problem for some people, so I rolled back my changes and installed the update. No change on my monitor. Nevertheless, it’d be a good idea to update OS X before trying this, since it may fix the issues with your particular hardware.

I recently bought a MacBook Pro (with ‘Retina’ screen), but when I hooked it up to my Dell U2410 monitor via HDMI cable I was shocked by the poor picture quality. The contrast was all wrong and text was misshapen. No amount of calibration in the monitor or software would fix it.

Short answer: OS X thinks my monitor is a TV, and is using the YCbCr colour space rather than RGB. I had to override an EDID setting to force the RGB colour space, and it is now working correctly.

Long answer: I haven’t owned a Mac for a while and h

@jknowles
jknowles / MWEblogpost.Rmd
Created May 27, 2013 22:30
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
library(RColorBrewer)
library(colorRamps)
pdf("rcolorsheet.pdf", paper="a4r", width=11.6, height=8.2, onefile=TRUE)
### page 1
# grDevices::colors
m <- matrix(1:660, 60, 11)
@dsparks
dsparks / off_diagonal.R
Created September 10, 2012 19:17
Modifying select off-diagonal items in a matrix
# A method for modifying only select off-diagonal items in a matrix
# From "Thierry" and "Ben Bolker"
# At http://stackoverflow.com/a/11759744/479554
# A sample matrix
size <- 6
mat <- matrix(seq_len(size ^ 2), ncol = size)
print(mat)
# A companion matrix that indicates how "off" a diagonal is: