从Python到R - time.sleep和break

时间:2015-02-27 20:58:06

标签: python r

如何用R?

编写这个时间逻辑
 while StatusTest('CSV', Short, username, ItemID, token)['status']!='completed':
        if StatusTest('CSV', Short, username, ItemID, token)['status'] == 'failed':
            print "CSV upload failed"
            break
        time.sleep(5)
        print ("Processing CSV")

这是我尝试过的:

while (accepted != 'completed'){
URL <- paste('http://',short,'.maps.arcgis.com/sharing/rest/content/users/',username,'/items/',ItemID,'/status?f=json&token=',token,sep = "")
x <- getURL(URL)
x <- fromJSON(((x)))
accepted<-x$statusMessage
print(accepted)
}

但没有time.sleepbreak,我真的不知道怎么做R

1 个答案:

答案 0 :(得分:2)

您可能想要使用Sys.sleep(5)

while (accepted != 'completed')
{
URL <- paste('http://',short,'.maps.arcgis.com/sharing/rest/content/',username,'/items/',ItemID,'/status?f=json&token=',token,sep = "")
x <- getURL(URL)
x <- fromJSON(((x)))
accepted<-x$statusMessage
Sys.sleep(5)
print(accepted)
}