Skip to content

Instantly share code, notes, and snippets.

@nickhepler
Last active January 23, 2016 03:37
Show Gist options
  • Save nickhepler/a32aefe185bee39c4d9a to your computer and use it in GitHub Desktop.
Save nickhepler/a32aefe185bee39c4d9a to your computer and use it in GitHub Desktop.

base

Data Structure

str(x)  # Compactly display the internal structure of an R object.
class(x)  # Return the object class.
dim(x)  # Retrieve or set the dimension of an object.
nrow(x)  # Return the number of rows (observations).
ncol(x)  # Return the number of columns (variables).
object.size(x)  # Provides an estimate memory used to store an R object.
names(x)  # Get or set the names of an object.
head(x)  # Returns the first part of a vector, matrix, table, data frame or function.
tail(x)  # Returns the last part of a vector, matrix, table, data frame or function.
summary(x)  # Produces result summaries of the results of various model fitting functions.
table(x$y)  # Uses the cross-classifying factors to build a contingency table of the counts at each combination of factor levels.

Missing Data

is.na(x)  # indicates which elements are missing.
na_count <- is.na(x)  
sum(na_count)  # Assign missing elements to variable and sum missing elemeents.

dplyr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment