[R] script to get data from a list of facebook users

Jorge Luis Salcedo Maldonado jorgelsalcedo at gmail.com
Mon Jan 19 00:22:54 CET 2015


I am using the Rfacebook package to get some data from a list of facebook
users, specifically I am using the getuser command.

I am trying to run this script


install_github("Rfacebook", "pablobarbera", subdir = "Rfacebook")




##Temporal token only 2 hours after you log in your Facebook profile


###Here you putt he token (you have to change every 2 h)

token <-

###To get information profile  from a list of users

mcPlist <- scan("facebookdirus.txt", what="", sep="\n")


res1 <- matrix(nrow=length(mcPlist), ncol=14)

rownames(res1) <- mcPlist

colnames(res1) <- c("id", "name", "username", "first_name", "last_name",
"gender", "locale","category","likes",
"picture","birthday","location","hometown", "relationship_status")

res1 <- data.frame(res1)

for (mcP in mcPlist){

  user <- getUsers(mcP, token, private_info = TRUE)

  res1[1, mcP] <- user$id

  res1[2, mcP]  <- user$name

  res1[3, mcP]  <- user$username

  res1[4, mcP]  <- user$first_name

  res1[5, mcP]  <- user$last_name

  res1[6, mcP] <- user$gender

  res1[7, mcP]  <- user$locale

  res1[8, mcP] <- user$category

  res1[9, mcP]  <- user$likes

  res1[10, mcP]  <- user$picture

  res1[11, mcP]  <- user$birthday

  res1[12, mcP]  <- user$location

  res1[13, mcP]  <- user$hometown

  res1[14, mcP]  <- user$relationship_status

  dfuser <- do.call("rbind", lapply(user, as.data.frame))

  write.xlsx(dfuser, file=paste(mcP, ".xlsx", sep = ""), row.names = F,


* I get the data of the first member of the list, but after that  always I
receive this error, *


 Error in match.names(clabs, names(xi)) :

  names do not match previous names"

I have been test with other commands different that "rbind" for instance
"rbind.fill", but alway is the same problem, evidently other is the problem

I am new on developing scripts, anyone maybe knows how I can solve this?

thanks for your attention and maybe excuse the novice


	[[alternative HTML version deleted]]

More information about the R-help mailing list