Created
September 18, 2012 20:39
-
-
Save Quantisan/3745710 to your computer and use it in GitHub Desktop.
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 data | |
c <- read.csv("data/cartier_sample_likes.csv", header=F) | |
names(c) <- c("user.id", "page.id") | |
s <- read.csv("data/swarovski_sample_likes.csv", header=F) | |
names(s) <- c("user.id", "page.id") | |
p <- read.csv("data/page_labels.csv", header=F) | |
names(p) <- c("page.id", "followers", "name") | |
require(stringr) | |
p$name <- as.factor(str_trim(as.character(p$name))) ## trim whitespace | |
cs <- rbind(s[s$user.id %in% c$user.id,], | |
c[c$user.id %in% s$user.id,]) # ppl in both cart and swar | |
cs <- unique(cs) | |
p.c <- merge(c, p, by="page.id") | |
p.s <- merge(s, p, by="page.id") | |
p.cs <- merge(cs, p, by="page.id") | |
# common pages of c and s | |
pcps <- rbind(p.s[p.s$page.id %in% p.c$page.id,], | |
p.c[p.c$page.id %in% p.s$page.id,]) | |
pcps <- unique(pcps) | |
print("Cartier users summary") | |
print(summary(p.c)) | |
print("Swarovski users summary") | |
print(summary(p.s)) | |
print("Users in both Cart and Swar summary") | |
print(summary(p.cs)) | |
print("Common pages to Cart and Swar users summary") | |
print(summary(pcps)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment