Ross Ihaka and Robert Gentleman Year
Total Page:16
File Type:pdf, Size:1020Kb
MULTI-FILES LOADER file_01.csv GGPLOT2 data(aes) + geom + labels R (Statistical computing) files <- list.files(pattern = “file_.*csv”) %>% ggplot(data = df, aes(x_col, y_col)) + geom() CHEET SHEET BY @CHARLSTOWN lapply(files, read_csv) %>% canvas + layer +...+ labs > general structure CREATOR: ROSS IHAKA AND ROBERT GENTLEMAN bind_rows() YEAR: 1995 ggplot(data = df) > canvas level STEABLE RELEASE (2020): 3.6.2 DATA FRAMES ACTIONS dplyr & tidyr aes(x_col, y_col) > aesthetics TOP FROM R: DPLYR, GGPLOT2, ESQUISSE, BIO DPLYR FUNCTIONS df %>% function geom_point() > geometry level CONDUCTOR, SHINY, LUBRIDATE, KNITR, TIDYR. rename(c_new = c1) > rename columns AESTHETICS aes(*) select(col) > select column ELEMENTAL LIBRARIES library( * ) select(-col) > drop column x_col, y_col > sets x,y elements library(dplyr) > Easy commands filter(c == “value”) > select rows label=labels > set ticks labels library(ggplot2) > Generate plots mutate(col = (c1+2)) > column mutations color > sets color values library(tidyverse) > Tidy data transmute(c1=c, c2=c/2) > drop & built cols alpha > sets the opacity library(kableExtra) > Table visualization arrange(des(c1)) > order by column fill = ‘color’ > sets the filled color library(knitr) > Regular exprs. join(df2) > join 2 data frames shape = class > set groups by class library(readr) > Files Reader group_by(col) > silent grooping group = class > sets plot by class library(stringr) > Strings treatment summarise(c* = max(c)) > after grooping shape > geometry shape size = 4 > sets the size TIDYR FUNCTIONS df %>% function install.packages(“name”) > Install library stroke > set boundary line ?library > Documentation gather(‘key‘, ‘value’, 2:4) > wide to long df GEOMETRIES ggplot() + geom BASIC FUNCTIONS df and columns spread( ‘key’, ‘value’) > long to wide df geom_point() > simple points geom_bar() > bars chart read_csv(“file.csv”) > data reader unite(col, ‘-’, c1, c2) > join 2 columns geom_smooth() > Inserts a function head(df) > show first rows jitter_geom() > points no overlap names(df) > object names separate(col, > split col by symbol c(c1, c2), ‘symbol’) geom_density() > continuous funct. colnames(df) > columns names geom_text() > plot text inside rownames(df) > rows names full_seq(c(1, 3, 4), step) > complete sequence geom_segment() > Plots a segment nrow(df) > number of rows stat_function() > inserts function ncol(df) > number of cols. separate_rows(c, > split values in row geom_boxplot() > box plot length(df) > object length sep = ‘&’) dim(df) > matrix dimension LABELS ggplot() + labs(*) summary(df) > summary by var. fill(column) > fill NAs in column title > main title str(df) > features structure replace_na(‘var‘) > replace NA for var df$col > extracts column subtitle > subtitle df[1:3 , 2:5] > subdf by index drop_na() > drop rows with NA x > x label df[, c(1:3, 5)] > columns by index y > y label typeof(col) > column type color > color caption > reference.