Skip to content

Instantly share code, notes, and snippets.

# https://stackoverflow.com/questions/64476043/
# https://stackoverflow.com/questions/1189759/
convertDirectoryR.toWin = function(myDir = getwd()) # "R:/data/state-capitals/final/"
{
cat( normalizePath(myDir) );
writeClipboard( normalizePath(myDir) ); # R:\data\state-capitals\final\
}
openDirectoryR.inWin = function(myDir = getwd()) # "R:/data/state-capitals/final/"
#' Convert String Matrix to Numeric Matrix
#'
#' @param m string matrix
#'
#' @return numeric matrix
#' @export
numericMatrix = function(m)
{
# Blender v2.74 (sub 0) OBJ File: 'Hand.blend'
# www.blender.org
mtllib Hand.mtl
o ZBrushPolyMesh3D
v 0.614360 0.281365 -0.675872
v 0.684894 0.445729 -0.634615
v 1.294752 1.048795 -0.574309
v 0.552541 0.233567 -0.579448
v 0.631207 0.406862 -0.474761
v 1.311582 1.012985 -0.257089
@MonteShaffer
MonteShaffer / classR.py
Last active October 22, 2017 19:15
Helper class to interface between R and python using rpy2 (From R persp)
# helper class to interface between R and python using rpy2
# © Monte J. Shaffer
# monte.shaffer@gmail.com
# MIT license
import numpy as np
import rpy2
import rpy2.robjects as robjects
import rpy2.robjects.packages as rpackages
from rpy2.robjects.packages import importr
# I wrote this in 2009 as part of my M.S. Stats - Statistical Computing Course
# Not all the bells and whistles, but should be understandable
# © Monte J. Shaffer
# monte.shaffer@gmail.com
# MIT license
myKmeans = function(data,clusters,maxIter=25)
{
data = as.matrix(data);
n = nrow(data);
@MonteShaffer
MonteShaffer / classKMeans.py
Created October 22, 2017 05:08
Python Kmeans class using numpy
# https://datasciencelab.wordpress.com/2014/01/15/improved-seeding-for-clustering-with-k-means/
import numpy as np
import random
from numpy import zeros
import matplotlib
matplotlib.use("qt4agg")
from matplotlib import pyplot as plt