Exploring Facebook Birthdays List

After reading the data and audit it to have same format for all entries, I use the “as.Date”" function to create dataframe that contains dates.

 library(tidyr)

 setwd('C:/Shmuel/Nanodegree/Explorer_Data_R')

# read the csv file 
 birth_day <- read.csv('birthdaysExample.csv',as.is=TRUE)
 
# convert the strings to dates and make sure the result have the same format 
 A<- birth_day$dates[nchar(birth_day$dates, type = "chars", allowNA = FALSE)==10]
 B<- birth_day$dates[nchar(birth_day$dates, type = "chars", allowNA = FALSE)<10]

# create the dataframe
better_birth_day <- c (as.Date(A,  format = "%m/%d/%Y") ,as.Date(B,  format = "%m/%d/%y") )

How many people share my birthday?

my_birth_day <- (as.Date("2014-04-08"))

A<- better_birth_day[better_birth_day==my_birth_day]

length(A)
## [1] 6

Which month contains the most number of birthdays?

# seperate the year, mounth and day in to different columns. 

df1<-data.frame(better_birth_day) 
df<- separate(df1, better_birth_day,c("year", "month", "day"), sep = "-")

# create a table that indicate the number of birthdays in each mounth and find the max
monthTable <- table(df$month)
names(monthTable) <- month.name
monthTable[which(monthTable == max(monthTable))]
## March 
##    98

How many birthdays are in each month?

# display the table 
monthTable
##   January  February     March     April       May      June      July 
##        89        79        98        81        72        93        86 
##    August September   October  November  December 
##        91        96        89        87        72

Which day of the year has the most number of birthdays?

dateTable <- table(df1$better_birth_day)
dateTable[which(dateTable ==max(dateTable) )]
## 
## 2014-02-06 2014-05-22 2014-07-16 
##          8          8          8

Do you have at least 365 friends that have birthdays on everyday

of the year?

bt <- table (df1$better_birth_day)
length(names(bt))
## [1] 348