我试图运行大小为59的循环,但R继续崩溃,这就是循环:
n=length(webpage)
count=0
i=1
for(i in 1:n)
{
#get the URL
u <- webpage[i]
doc <- getURL(u)
#get the text from the body
html <- htmlTreeParse(doc, useInternal = TRUE)
txt <- xpathApply(html, "//body//text()[not(ancestor::script)][not(ancestor::style)][not(ancestor::noscript)]", xmlValue)
txt<-toString(txt)
txt
#clean
txt<-(str_replace_all(txt, "[\r\n\t,]" , ""))
txt<-tolower(txt)
search <- c("wi-fi","router","switch","adsl","wireless")
stri_count_fixed(txt, search)
count[i]<-sum(stri_count_fixed(txt, search))
}
count
我试过3并且工作但是15没有