Google R 代币创建过程分析

Google Analytics in R Token creation Process

所以,我是 R 的新手,我还在学习。 我有一个令牌来验证与 R 的 google 分析连接。 目前我只是在我的脚本中使用 Load("./token") 来自动加载令牌并提取数据。

我想知道我是否可以在脚本中包含一些内容 检查令牌是否存在,如果不存在,我想完成整个令牌创建过程-

client.id<-"xyz"
client.secret<-"123"

token=Auth(client.id,client.secret)
save (token,file="./token")

然后 运行 Load("./token")

如果令牌已经存在,则跳过创建令牌过程,直接运行 Load("./token")

如有任何帮助,我们将不胜感激。谢谢!

像这样使用 file.exists() 函数:

if(!file.exists("./Token")){
 client.id<-"xyz"
 client.secret<-"123"
 token=Auth(client.id,client.secret)
 save (token,file="./token.txt")
 load("./token")
} else {load("./token")