[R] using foreach function with gtrendsR
samarvir singh
samarvir1996 at gmail.com
Wed Apr 27 18:26:47 CEST 2016
I have this code which is working
library("checkpoint")
library("gtrendsR")
library("doParallel")
cl<-makeCluster(4)
registerDoParallel(cl)
gconnect(usr = "email at gmail.com", psw = "password", verbose = FALSE)
names <- c("apple","shit", "android", "rocks")
formula <- function(x){
x0 <- gtrends(x, res = "7d")
x1 <- x0[3]
x2 <- as.data.frame(x1)
x3 <- x2[1,2]return(x3)}
for( x in names)
{
x5 <- rbind(x5,formula(x))
}
Now, I want to process this code with parallel processing, so I am using
foreach function
How can I do the same for foreach loop?
[[alternative HTML version deleted]]
More information about the R-help
mailing list