Reputation: 53
I've been trying for a while to use the library opencpu
to import some Gdrive files (binary files, not Gsheets or Gdocs) using the R library googledrive
. My code works great locally or deployed as a Shiny
application but it seems Opencpu
can't read .httr-oauth
(or I don't know where to put it in order for Opencpu to be able to read it). Anyway I always get the following error: "failed to create server"
.
I've tried to save the auth token as a local file and to load it in opencpu
without success, I've tried to put the .httr-oauth
file in data folder, in www folder, in inst/www folder and even in R folder, but it doesn't work.
My code is like this (I removed references to actual Gdrive files):
Estrai <- function(dataset,start=NULL,end=NULL) {
library(googledrive)
library(foreign)
library(openair)
drive_auth()
x<-as_id("https://drive.google.com/open?id=xxxxxxx")
drive_download(x,overwrite=TRUE)
x2<-as_id("https://drive.google.com/open?id=xxxxxxx")
drive_download(x2,overwrite=TRUE)
spc<-read.dta("xxxxxx.dta")
spc$date<-as.POSIXct(paste0(spc$year,"-",spc$month,"-",spc$day," ",spc$hh,":00"),format="%Y-%m-%d %H:%M")
bo<-read.dta("xxxx.dta")
bo$date<-as.POSIXct(paste0(bo$year,"-",bo$month,"-",bo$day," ",bo$hh,":00"),format="%Y-%m-%d %H:%M")
if (dataset=="dr"){
uscita1=paste0("SPC: da ",min(spc$date)," a ",max(spc$date))
uscita2=paste0("BO: da ",min(bo$date)," a ",max(bo$date))
uscita=paste(uscita1,uscita2,sep="\n")
}
if (dataset=="spc"){
uscita=selectByDate(spc,start,end)
}
if (dataset=="bo"){
uscita=selectByDate(bo,start,end)
}
return(uscita)
}
'''
Any idea? Thank you.
Upvotes: 3
Views: 54