Skip to content

Loading .RData from Internet

6 messages · zhiji19, Ivan Calandra, Rainer M Krug +1 more

#
Dear All,

Can you please suggest me a correct way to load the following R data frame
from the internet and save it to the hard drive?

The following is what I tried:
However, when I used dim() to check the dataset, I got:
[1] 11085  1

The correct dimension should be 5000 and 10.

Many Thanks.
#
Try with load() instead of read.table()
read.table() is for csv, txt... files.
load() is for R files

Ivan

Le 12/6/2010 09:35, zhiji19 a ?crit :

  
    
#
I tried the load() already. It does not work. The erro is shown as following:

Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
  cannot open compressed file
'http://rss.acs.unt.edu/Rdoc/library/twang/data/raceprofiling.RData',
probable reason 'Invalid argument'
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 12/06/2010 10:29 AM, zhiji19 wrote:
load() works - I downloaded the data and then used load() - it works.

I don't know if load() accepts an URL as a source, because that gave me
IMMEDIATELY an error.

Cheers,

Rainer
- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:        +33 - (0)9 53 10 27 44
Cell:       +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:      Rainer at krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz8sJQACgkQoYgNqgF2egr/owCdETedL3WT81cJ93WGL/8oCvi7
aAgAniZtSnlK2jBcSeIUXGffls+fdZ3n
=LVfP
-----END PGP SIGNATURE-----
L
#
On Mon, Dec 6, 2010 at 8:29 PM, zhiji19 <zhiji19 at gmail.com> wrote:
a<-url("http://rss.acs.unt.edu/Rdoc/library/twang/data/raceprofiling.RData")
load(a)
#
You can create a connection to the URL and load() the connection.
Like this:
con <- 
url('http://rss.acs.unt.edu/Rdoc/library/twang/data/raceprofiling.RData')
load(file=con)
close(con)
str(raceprofiling)

But the easiest way is to save the file and then load it.

Ivan

Le 12/6/2010 10:44, Rainer M Krug a ?crit :