Skip to content

Instantly share code, notes, and snippets.

View javierluraschi's full-sized avatar
👨‍💻
Coding @hal9ai

Javier Luraschi javierluraschi

👨‍💻
Coding @hal9ai
View GitHub Profile
@javierluraschi
javierluraschi / importing-modern-data-into-r
Last active August 16, 2017 05:19
Importing Modern Data - useR 2016
---
title: "Importing Modern Data into R"
author: Javier Luraschi
date: June 29, 2016
output: revealjs::revealjs_presentation
---
## Overview
* Importing Data
@javierluraschi
javierluraschi / Build-R-Windows.Rmd
Last active March 28, 2019 17:18
Build R from Windows
##A Partial Guide for Building R in Windows
**Summary:** Start with this guide [R Admin - The Windows Toolset](https://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset) and **carefully follow each step**. Use the information bellow as an overview not a replacement to the mentioned guide.
### Overview ###
Download RTools, install for full develoment
Install R sources from SVN
@javierluraschi
javierluraschi / installing-and-initializing-mysql-osx.Rmd
Last active June 13, 2017 21:56
Installing and Initializing MySQL in OS X
Install MySQL in OS X using brew: `brew install mysql`, start the service `mysql.server start` and login with `mysql -uroot` to create a database as follows:
```{sql}
CREATE DATABASE sparklyr;
USE sparklyr;
CREATE TABLE `person` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(30) DEFAULT NULL,
`last_name` varchar(30) DEFAULT NULL,
@javierluraschi
javierluraschi / installing-and-initializing-cassandra-osx.Rmd
Created June 13, 2017 22:25
Installing and Initializing Cassandra in OS X
Install Cassandra:
```
curl -OL http://downloads.datastax.com/community/dsc.tar.gz
tar -xzf dsc.tar.gz
cd dsc-cassandra-3.0.9/bin
./cassandra
```
Create some tables:
@javierluraschi
javierluraschi / batman.R
Last active August 19, 2017 20:41
Batman Function
# Credit: https://www.r-bloggers.com/the-batmans-ecosystem/
f1u <- function(x) ifelse ((abs(x) > 3 & abs(x) <= 7), 3*sqrt(1-(x/7)^2), 0)
f1d <- function(x) ifelse ((abs(x) >= 4 & abs(x) <= 7), -3*sqrt(1-(x/7)^2), 0)
f2u <- function(x) ifelse ((abs(x) > 0.50 & abs(x) < 0.75), 3*abs(x)+0.75, 0)
f2d <- function(x) ifelse ((abs(x) > -4 & abs(x) < 4), abs(x/2)-(3*sqrt(33)-7)*x^2/112-3 + sqrt(1-(abs(abs(x)-2)-1)^2), 0)
f3u <- function(x) ifelse ((x > -0.5 & x < 0.5), 2.25, 0)
f4u <- function(x) ifelse ((abs(x) > 1 & abs(x) <= 3), 6 * sqrt(10)/7 + (1.5 - 0.5 * abs(x)) * sqrt(abs(abs(x)-1)/(abs(x)-1)) - 6 * sqrt(10) * sqrt(4-(abs(x)-1)^2)/14, 0)
f5u <- function(x) ifelse ((abs(x) >= 0.75 & abs(x) <= 1), 9-8*abs(x), 0)
fu <- function (x) f1u(x) + f2u(x) + f3u(x) + f4u(x) + f5u(x)
@javierluraschi
javierluraschi / RPostgreSQL_OSX.Rmd
Created September 15, 2017 00:42
RPostgreSQL in OS X
## install
```{bash}
brew install postgres
```
## start
```{bash}
pg_ctl -D /usr/local/var/postgres -l logfile start
@javierluraschi
javierluraschi / using-tensorflow-in-emr-with-sparklyr.md
Last active January 20, 2020 16:53
Using TensorFlow in EMR with sparklyr

A script to demonstrate using TensorFlow in Spark with Amazon EMR and sparklyr.

  1. Create an EMR cluster for sparklyr, connect to EMR and install required tools:
install.packages(tensorflow)
devtools::install_github("rstudio/tfdeploy")
  1. Connect to Spark using sparklyr, copy some data and the mtcars TensorFlow model:
https://api.github.com/search/repositories?q=language:R+stars:%3C10000&page=10&sort=stars
...
https://api.github.com/search/repositories?q=language:R+stars:%3C1&page=10&sort=stars
@javierluraschi
javierluraschi / install-rstudio-server-suse.Rmd
Created May 29, 2018 21:03
Install RStudio Server in Suse
Verified using Amazon EC2 Suse 12 machine.
See [http://download.opensuse.org/repositories/devel:/languages:/R:/patched/](http://download.opensuse.org/repositories/devel:/languages:/R:/patched/), then from [https://forums.opensuse.org/showthread.php/517620-Installing-R](https://forums.opensuse.org/showthread.php/517620-Installing-R):
```bash
zypper ar -f http://download.opensuse.org/repositories/devel:/languages:/R:/patched/openSUSE_12.3/ R-patched
zypper --gpg-auto-import-keys ref
zypper in R-patched R-patched-devel
```
@javierluraschi
javierluraschi / rstudio-1.2-package-improvements.Rmd
Last active August 9, 2018 01:10
RStudio 1.2: Package Improvements
RStudio 1.2 comes with improvements to manage **package repos** and adds better support to packages that provide **testing infrastructure** and **database connectivity**.
## Package Repos
Some organizations set up private CRAN repos to share internal packages, one way of accomplishing this is by
creating a private CRAN repos as described in the [R Admin Guide](https://cran.r-project.org/doc/manuals/R-admin.html#Setting-up-a-package-repository). Other projects rely on `drat` to provide CRAN-compatible repos. With RStudio 1.2 you can easily configure and prioritize: private, primary or secondary CRAN repos through the preferences pane. For instance, at the
time of this writting, the `limer` package from the `cloudyr` project was not available on CRAN; however, the `cloudyR`
project provides a `drat` repo `http://cloudyr.github.io/drat` that we can easily add as a secondary repo:
`IMAGE`