[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
Hello
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
library(devtools)
install_github("Rfacebook", "pablobarbera", subdir = "Rfacebook")
setwd("C:/Users/z470/OneDrive/Documentos/JIP/DirTecnoPO")
###C:\Users\z470\OneDrive\Documentos\JIP\DirTecnoPO
library(Rfacebook)
##Temporal token only 2 hours after you log in your Facebook profile
###
https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname&version=v2.2
###Here you putt he token (you have to change every 2 h)
token <-
"CAACEdEose0cBAGnRva45VJv042jvgVTrQrfg5WASTpmnmUZA1KV8vZBViziRZBjR7mo5regkbgxyexQTZBGZBqQNP114sW5XXM2nup9ZAZAOHt48aTUbbH0v2TnZBcKADuZBZBZBgrtd0OlifBZBgnZCdV14OeZBPqoms5SQ6s6t1wpXY8ZA8tEg7KjgNqmbct2LdKQG8j3tt1iqRL2telZBDLT6dpL3"
###To get information profile from a list of users
mcPlist <- scan("facebookdirus.txt", what="", sep="\n")
library(xlsx)
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,
col.names=T)
}
* 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