getwd()
## [1] "C:/Users/user/Documents/R"
list.files()
## [1] "demystifying.R"
## [2] "demystifyingR2_v3.html"
## [3] "demystifyingR2_v3.Rmd"
## [4] "EDA_Course_Materials.zip"
## [5] "EDA_materials"
## [6] "L2- R Basics (3 hrs) Videos.zip"
## [7] "L3- Explore One Variable (4 hrs) Videos.zip"
## [8] "lesson 3.Rmd"
## [9] "lesson_3.html"
## [10] "lesson_3.Rmd"
## [11] "my first knit.Rmd"
## [12] "my_first_knit.html"
## [13] "quakes.dat.txt"
## [14] "reddit.csv"
## [15] "swirl_courses-master"
## [16] "swirl_courses-master.zip"
## [17] "What_is_a_RMD_file.Rmd"
## [18] "win-library"
pf<-read.csv("C:/Users/user/Documents/R/EDA_materials/EDA_Course_Materials/lesson3/pseudo_facebook.tsv", sep = '\t')
names(pf)
## [1] "userid" "age"
## [3] "dob_day" "dob_year"
## [5] "dob_month" "gender"
## [7] "tenure" "friend_count"
## [9] "friendships_initiated" "likes"
## [11] "likes_received" "mobile_likes"
## [13] "mobile_likes_received" "www_likes"
## [15] "www_likes_received"
library(ggplot2)
qplot(data=pf, x=dob_year)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
qplot(data=pf, x=dob_day)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
##Friends count
names(pf)
## [1] "userid" "age"
## [3] "dob_day" "dob_year"
## [5] "dob_month" "gender"
## [7] "tenure" "friend_count"
## [9] "friendships_initiated" "likes"
## [11] "likes_received" "mobile_likes"
## [13] "mobile_likes_received" "www_likes"
## [15] "www_likes_received"
qplot(data=pf,x=friend_count)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
##limiting the Axes
qplot(data=pf,x=friend_count,xlim=c(1,1000))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 4913 rows containing non-finite values (stat_bin).
## Warning: Removed 1 rows containing missing values (geom_bar).
## Second method
qplot(data=pf,x=friend_count)+
scale_x_continuous(limits = c(0,1000))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 2951 rows containing non-finite values (stat_bin).
##Adjusting the Binwidth
qplot(data=pf,x=friend_count, binwidth=25)+
scale_x_continuous(limits = c(0,1000), breaks = seq(0,1000,50))
## Warning: Removed 2951 rows containing non-finite values (stat_bin).
## Slipliting gender wise
qplot(data=pf,x=friend_count, binwidth=25)+
scale_x_continuous(limits = c(0,1000), breaks = seq(0,1000,50))+facet_wrap(~gender)
## Warning: Removed 2951 rows containing non-finite values (stat_bin).
##Omitting NA Gender Observation
qplot(data=subset(pf,!is.na(gender)),x=friend_count, binwidth=25)+
scale_x_continuous(limits = c(0,1000), breaks = seq(0,1000,50))+facet_wrap(~gender)
## Warning: Removed 2949 rows containing non-finite values (stat_bin).
##Using the na.omit() wrapper
qplot(data=na.omit(pf),x=friend_count, binwidth=25)+
scale_x_continuous(limits = c(0,1000), breaks = seq(0,1000,50))+facet_wrap(~gender)
## Warning: Removed 2949 rows containing non-finite values (stat_bin).
##Statistics ‘by’ Gender
table(pf$gender)
##
## female male
## 40254 58574
by(pf$friend_count,pf$gender,summary)
## pf$gender: female
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0 37 96 242 244 4923
## --------------------------------------------------------
## pf$gender: male
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0 27 74 165 182 4917
qplot(data=pf,x=tenure,binwidth=30,
color=I('black'),fill=I('#099dd9'))
## Warning: Removed 2 rows containing non-finite values (stat_bin).
##Tenure solution by years
qplot(data=pf,x=tenure/365,binwidth=0.25,xlab = 'Number of years using facebook',
ylab = 'Number of users in sample',
color=I('black'),fill=I('#ffbbdd'))+scale_x_continuous(breaks = seq(1,7,1),limits = c(0,7))
## Warning: Removed 26 rows containing non-finite values (stat_bin).
will continue tomorrow and i stop at video number 25.