Cheatography
https://cheatography.com
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 |
|
install.packages("package")
|
|
|
|
const fs = require("fs");
|
Reading CSV Files
|
|
const fs = require("fs");
|
pd.read_csv("file.csv")
|
read_csv("file.csv")
|
readFileSync("file.csv")
|
Python - Functions
Python |
R |
JavaScript |
def fxnName(arg1,arg2): statements return val
|
fxnName <- function(arg1,arg2){ statements return(value) }
|
function fxnNam(arg1){statements}
|
Python - Type Conversion
int(var)
float(var)
str(var)
|
|
|
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()
|
|