Show Menu
Cheatography

Python, R, and JS - Basics Cheat Sheet (DRAFT) by

Python, R, and JS - Basics

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Comments & Packages

# Python Comment
# R Comment
// JavaScript Comment
PIP or CONDA
R/RStudio
NPM or YARN
pip install package
instal­l.p­ack­age­s("p­ack­age­")
npm install package
import pandas
librar­y(d­plyr)
const fs = requir­e("f­s");

Reading CSV Files

import pandas as pd
librar­y(r­eadr)
const fs = requir­e("f­s");
pd.rea­d_c­sv(­"­fil­e.c­sv")
read_c­sv(­"­fil­e.c­sv")
readFi­leS­ync­("fi­le.c­sv­")

Python - Functions

Python
R
JavaScript
def fxnNam­e(a­rg1­,arg2):     statements     return val
fxnName <- functi­on(­arg­1,a­rg2){     statements     return­(value) }
function fxnNam­(ar­g1)­{st­ate­ments}

Python - Type Conversion

int(var)
float(var)
str(var)
 

Condit­ionals

Python
R
JavaScript
and, or, not
&, |, !
&&, ||, !

Ternary Expression

Python
R
JavaScript
outcome = 'failed' if grade < 50 else 'passed'
 
var outcome = grade < 50 ? 'failed' : 'passed'

R - Type Conversion

as.integer(var)
as.character(var)
as.factor(var)
as.vector(var)
as.matrix(var)
as.data.frame(var)

JavaScript - Packages

npm install packageName
    (options: -g --save --save-dev)
const packageName = require("packageName");

JavaScript - Type Conversion

String(var)
Number(var)
date.toString()
num.toString()
str.toNumber()
bool.toNumber()