[問題] 錯誤訊息不知哪裡出錯
我嘗試抓 web of science的資料,但是出現錯誤訊息,不曉得哪裡出問題?
謝謝
##################
wosurl<-"http://apps.webofknowledge.com.mutex.gmu.edu/full_record.do?product=MEDLINE&search_mode=AdvancedSearch&qid=3&SID=2CCAKeGnJ4AWExADGqh&page=1&doc=1"
numdocs<-733
setwd("C:\\Users\\R3\\Downloads\\wos")
# loading library
library(stringr)
# dowloading the html code and parsing data
wosurl_str<-substr(wosurl, 1, (nchar(wosurl)-1))
for(k in 1:numdocs)
{
print(paste("--Record number: ",k," (out ",numdocs,")--",sep=''))
url<-paste(wosurl_str,k,sep='')
all_lines<-readLines(url)
line<-all_lines[str_detect(all_lines,"UT=WOS:")]
line_str<-unlist(strsplit(str_extract(line,"UT=WOS:.+"),"&"))
wosut<-sub('WOS:','',line_str[1])
line<-all_lines[str_detect(all_lines,"NCBI_DB&PMID")]
line_str<-unlist(strsplit(str_extract(line,"PMID.+"),"&"))
pmid<-line_str[1]
data<-cbind(pmid,wosut)
write.table(data,file='wosut.txt',row.names=F,col.names=F,append=T,sep=",")
write.table(all_lines,file=paste('wos',pmid,'.txt',sep=''),row.names=F,col.names=F,append=F)
}
# creating the search string for WoS
uts<-read.csv(file="wosut.txt",header=F,sep=",",fill=T)
uts<-subset(uts,uts[,2]!="")
searchwos<-paste(uts[,2],collapse=' OR ')
write.table(searchwos,file='search.txt',row.names=F,col.names=F,append=F,quote=F)
錯誤訊息:
> # creating the search string for WoS
> uts<-read.csv(file="wosut.txt",header=F,sep=",",fill=T)
Error in read.table(file = file, header = header, sep = sep, quote = quote,
:
no lines available in input
> uts<-subset(uts,uts[,2]!="")
Error in subset(uts, uts[, 2] != "") : object 'uts' not found
> searchwos<-paste(uts[,2],collapse=' OR ')
Error in paste(uts[, 2], collapse = " OR ") : object 'uts' not found
>
write.table(searchwos,file='search.txt',row.names=F,col.names=F,append=F,quote=F)
Error in is.data.frame(x) : object 'searchwos' not found
>
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 69.143.188.208
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1440810668.A.527.html
→
08/29 10:31, , 1F
08/29 10:31, 1F
→
08/29 10:32, , 2F
08/29 10:32, 2F
→
08/29 10:32, , 3F
08/29 10:32, 3F
→
08/29 10:39, , 4F
08/29 10:39, 4F
→
08/29 10:39, , 5F
08/29 10:39, 5F
→
08/29 10:40, , 6F
08/29 10:40, 6F
→
08/29 10:40, , 7F
08/29 10:40, 7F
→
08/29 10:45, , 8F
08/29 10:45, 8F
→
08/29 10:55, , 9F
08/29 10:55, 9F
→
08/29 10:55, , 10F
08/29 10:55, 10F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章