Skip to content
Back to formatted view

Raw Message

Message-ID: <CAKJ8KVjgTbyzWF=_Y_BBjGBc4ghaK06b4W4efPjwBSOnZQ2EuA@mail.gmail.com>
Date: 2017-02-10T01:56:07Z
From: Ryan Utz
Subject: Inconsistent error opening connection on URL

Hello,

I'm trying to automatically download online data using a URL. Half the time
the code works, the other time I get this error:

Error in file(con, "r") : cannot open the connection

But I cannot for the life of me figure out why it works sometimes and not
others. Reading online data is relatively new for me. Snooping around on
this error shows that folk use this

setInternet2(TRUE)

but that doesn't work in my case, as I just end up with this error:

Error in setInternet2(TRUE) : use != NA is defunct

Any tips on resetting a connection when such errors occur? Here's an
example of one of the specific URLs I'm trying to read:

URL.1=paste('
http://pick18.discoverlife.org/mp/20m?plot=2&kind=Hypoprepia+fucosa&site=33.9+-83.3&date1=2011,2012,2013,2014,2015&flags=build_txt:
',sep='')
readLines(URL.1)

URL.2=paste('
http://pick18.discoverlife.org/tmp/Hypoprepia_fucosa_33.9_-83.3_2011,2012,2013,2014,2015.txt
',sep='')
X=read.delim(URL.2)

Thanks,
Ryan

-- 

Ryan Utz, Ph.D.
Assistant professor of water resources
*chatham**UNIVERSITY*
Home/Cell: (724) 272-7769

	[[alternative HTML version deleted]]