View this code at http://livecoding.io/11153443
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import unicode_literals | |
import requests | |
import json | |
import time | |
import codecs | |
import sys | |
UTF8Writer = codecs.getwriter('utf8') | |
sys.stdout = UTF8Writer(sys.stdout) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
ctmeet <- read.csv("meetup_groups.csv", quote = "", | |
row.names = NULL, | |
stringsAsFactors = FALSE) | |
# Adding column names | |
colnames(ctmeet) <- c("Area","Group","Created","Neighborhood","State","Category","Members","Who") | |
# Converting the Date group was created into a recognized format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
teams <- c(“Patriots”,”Red Sox”,”Celtics”) | |
losses <- c(5,13,21) | |
away <- c(TRUE,FALSE,TRUE) | |
sports <- data.frame(teams,losses,away) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example for a Mac | |
setwd(“~/Downloads”) | |
# Example for a PC | |
setwd(“C:/User/Downloads”) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read in CSV file, assign it to a variable | |
earnings <- read.csv("Employee_Earnings_Report_2014.csv", stringsAsFactors=FALSE) | |
# Why the stringsAsFactors=FALSE? Because you're telling to interpret the text in the spreadsheet as a String, not a Factor | |
# Why is R obsessed with Factors? Blame statisticians. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How many rows? | |
nrow(earnings) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Look at the first five rows in the Console | |
head(earnings) | |
# Alternatively, to look at the last five rows | |
foot(earnings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Investigate the structure of the dataframe | |
str(earnings) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Change column to number format (first you have to strip out the $) | |
#The $ is a special character | |
earnings$TOTAL.EARNINGS <- gsub("\\$", "", earnings$TOTAL.EARNINGS) | |
#Function to change the format to numeric | |
earnings$TOTAL.EARNINGS <- as.numeric(earnings$TOTAL.EARNINGS) |