作者evilove (愿意感动就是一种享受)
看板R_Language
标题[问题] 错误讯息不知哪里出错
时间Sat Aug 29 09:11:05 2015
我尝试抓 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://webptt.com/cn.aspx?n=bbs/R_Language/M.1440810668.A.527.html
1F:→ allen1985: read.csv 是用来读.csv档 但你的file是.txt 08/29 10:31
2F:→ allen1985: 是着用read.table 不行的话让大家下载你的资料 08/29 10:32
3F:→ allen1985: 很多高手就可以知道问题在哪了 08/29 10:32
4F:→ celestialgod: 楼上不是这个问题喔XD 他write.table sep用comma,r 08/29 10:39
5F:→ celestialgod: ead.csv应该可以work 08/29 10:39
6F:→ celestialgod: 他应该是写入的data没有资料才造成错误,不过要跑跑 08/29 10:40
7F:→ celestialgod: 看程式才知道为啥没写入 08/29 10:40
8F:→ allen1985: 谢谢C大 08/29 10:45
9F:→ evilove: 忘了说,我是校外用帐号密码连那资料库,请问要怎麽加这 08/29 10:55
10F:→ evilove: 进去? 08/29 10:55