Skip to content

Instantly share code, notes, and snippets.

@mGalarnyk
Last active December 31, 2016 17:55
Show Gist options
  • Save mGalarnyk/88a59775579422d035d6f99db6ba9c5e to your computer and use it in GitHub Desktop.
Save mGalarnyk/88a59775579422d035d6f99db6ba9c5e to your computer and use it in GitHub Desktop.
R programming Coursera John Hopkins Week 1 Review Suggestion Showing data.table functionality https://medium.com/@GalarnykMichael/in-progress-review-course-2-r-programming-jhu-coursera-ad27086d8438#.vclier2hw
# Reading in data
quiz_data <- fread('hw1_data.csv')
# Column names of the dataset
names(quiz_data)
# First two rows
quiz_data[c(1,2)]
# Number of rows in data.table
nrows(quiz_data)
# Extracting the last 2 rows of the data.table (either expression would work)
tail(quiz_data,2)
quiz_data[c(.N-1,.N)]
# Removing Missing Values
quiz_data[complete.cases(quiz_data),]
# Ozone values are above 31 and Temp values are above 90. etc
quiz_data[Ozone > 31 & Temp > 90]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment