栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

R如何在不知道长度的情况下进行for循环?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

R如何在不知道长度的情况下进行for循环?

library(RSelenium)checkForServer()startServer()Sys.sleep(5)re<-remoteDriver()re$open()re$navigate("http://espn.go.com/mens-college-basketball/playbyplay?gameId=400830392")shotchart <- data.frame(shot=as.vector(0), class=as.vector(0), data_homeaway=as.vector(0),   data_period=as.vector(0), player_id=as.vector(0), data_text=as.vector(0),  location=as.vector(0), gamenumber= as.vector(0))error="Error : t Summary: NoSuchElementn t Detail: An element could not be located on the page using the given search parameters.n t class: org.openqa.selenium.NoSuchElementExceptionn"i<-1element=0while ((i>0)&(element[1]!=error)){  text <-paste0("//*[(@)]//*[(@id)][",i,"]")  element<- try(unlist(re$findElement(using='xpath', text)$getElementAttribute('id')),silent = TRUE)  if (element[1]==error)    break;  shotchart[nrow(shotchart)+1,1]<- unlist(re$findElement(using='xpath',text)$getElementAttribute('id'))  shotchart[nrow(shotchart),2]<- unlist(re$findElement(using='xpath', text)$getElementAttribute('class'))  shotchart[nrow(shotchart),3]<-unlist(re$findElement(using='xpath', text)$getElementAttribute('data-homeaway'))  shotchart[nrow(shotchart),4]<-unlist(re$findElement(using='xpath', text)$getElementAttribute('data-period'))  shotchart[nrow(shotchart),5]<-unlist(re$findElement(using='xpath', text)$getElementAttribute('data-shooter'))  shotchart[nrow(shotchart),6]<-unlist(re$findElement(using='xpath', text)$getElementAttribute('data-text'))  shotchart[nrow(shotchart),7]<-unlist(re$findElement(using='xpath', text)$getElementAttribute('style'))  shotchart[nrow(shotchart),8]<-i-1  i<-i+1}

我不确定您的变量k是什么意思。

我从所有评论中获得了建议。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/417661.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号