Witshaper is the Professional (Computing Skills, English Learning and Soft Skills) Skill Development Training Center. We provide Professional IT Courses and Soft Skill Training in Dehradun to Students, Employees and organization. Who wish to pursue a career in IT Technology. Witshaper is led by a motivated team of IT experts and Soft Skill Professionals. We provide high quality trainings. Our Emphasis is on giving the practical knowledge to the students, so that they will get to know in depth and never forget what they opt, we provide to the students real learning environment. Witshaper prepares students and professionals to be the part of this growing industry. Be a part of Witshaper and get your dreams successful

Saturday 10 January 2015

face book page analysis commands in R Language


Face book page analysis steps

install.packages("Rook")

Installing package into ‘E:/Users/cherub/Documents/R/win-library/3.1’

(as ‘lib’ is unspecified)

trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/Rook_1.1-1.zip'

Content type 'application/zip' length 278588 bytes (272 Kb)

package ‘Rook’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in

E:\Users\cherub\AppData\Local\Temp\Rtmp4I7BWi\downloaded_packages

> install.packages("Rfacebook")

Installing package into ‘E:/Users/cherub/Documents/R/win-library/3.1’

(as ‘lib’ is unspecified)

trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/Rfacebook_0.4.zip'

Content type 'application/zip' length 56670 bytes (55 Kb)

package ‘Rfacebook’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in

E:\Users\cherub\AppData\Local\Temp\Rtmp4I7BWi\downloaded_packages

> require("Rfacebook")

Loading required package: Rfacebook

Loading required package: httr

Loading required package: rjson

package ‘Rfacebook’ was built under R version 3.1.2

> page_name <- "forbes"

"CAACEdEose0cBABPMO40HvHNn0NZBxlXkRZBal0V2bgPGjRnZACznRzxwrqtT0DYDwGh36dbBpVL0

f5nTsL6ZBA7lgfGJrfkb08waKtRrEHKVjgRcDgE8S5oPC7VpSAFeYtgXAlaX3IquKADT5sn89f8CgYyV6k3I

gIaZBB8HT9cnqXwNzLGkMdt3ZBu9PwIO6bWfV7ZB46FufYoPxMp1SW6"

> page <- getPage(page_name, token, n = number_posts, feed = FALSE)

> data_frame_gender <-

data.frame(post=character(),male=numeric(),female=numeric(),etc=numeric(),likes=numeric(),type=chara

cter(),stringsAsFactors=FALSE)

> for(i in 1:length(posts))

+     post <- getPost(temp,token)

+     data_frame_gender[i,1] <- post$post$message

+     data_frame_gender[i,5] <- post$post$likes

+     data_frame_gender[i,6] <- post$post$type

+     gender_frame <- data.frame(gender=character(),stringsAsFactors=FALSE)

+     for(j in 1:length(post$likes$from_id))

+         likes <- post$likes$from_id

+         user_id <- likes[j]

+         user <- getUsers(user_id,token=token)

+         gender <- user$gender

+         gender_frame[nrow(gender_frame)+1,] <- gender

+     number_males <- nrow(subset(gender_frame, gender=="male"))

+     number_females <- nrow(subset(gender_frame, gender=="female"))

+     number_etc <- data_frame_gender[i,5] - (number_males+number_females)

+     data_frame_gender[i,2] <- number_males

+     data_frame_gender[i,3] <- number_females

+     data_frame_gender[i,4] <- number_etc

> for(i in 1:length(posts))

+     #dataframe values:

+     post <- getPost(temp,token)

+     data_frame_gender[i,1] <- post$post$message

+     data_frame_gender[i,5] <- post$post$likes

+     data_frame_gender[i,6] <- post$post$type

+     gender_frame <- data.frame(gender=character(),stringsAsFactors=FALSE)

+     for(j in 1:length(post$likes$from_id))

+         likes <- post$likes$from_id

+         user_id <- likes[j]

+         user <- getUsers(user_id,token=token)

+         gender <- user$gender

+         gender_frame[nrow(gender_frame)+1,] <- gender

+     number_males <- nrow(subset(gender_frame, gender=="male"))

+     number_females <- nrow(subset(gender_frame, gender=="female"))

+     number_etc <- data_frame_gender[i,5] - (number_males+number_females)

+     data_frame_gender[i,2] <- number_males

+     data_frame_gender[i,3] <- number_females

+     data_frame_gender[i,4] <- number_etc

c(sum(data_frame_gender$male),sum(data_frame_gender$female),sum(data_frame_gender$etc))

> pct <- round(slices/sum(slices)*100)

> lbls <- names(data_frame_gender[2:4])

> lbls <- paste(lbls, pct) # add percents to labels

> lbls <- paste(lbls,"%",sep="") # ad % to labels

> pie(slices, labels = lbls, main="Gender Distribution of all analyzed posts")









face book page analysis

2 comments:

  1. Great post full of useful tips! My site is fairly new and I am also having a hard time getting my readers to leave comments. Analytics shows they are coming to the site but I have a feeling “nobody wants to be first”.
    Buy Facebook Likes

    ReplyDelete