0

I am following the examples in the book "Spatial Analysis with R". I have loaded the sp package and I am trying to read the table using:

 Cran_df<-read.table("CRAN051001a.txt", header = TRUE)

I am receiving the errors:

 Error in file(file, "rt") : cannot open the connection
 In addition: Warning message:
 In file(file, "rt") :
 cannot open file 'CRAN051001a.txt': No such file or directory

How do I get the required data for this exercise?

OpenSauce
  • 354
  • 2
  • 14

1 Answers1

2

By using the full URL:

Cran_df<-read.table("http://www.asdar-book.org/datasets/CRAN051001a.txt", header = TRUE)

Now your object Cran_df should be ok:

str(Cran_df)

'data.frame':   54 obs. of  6 variables:
$ place: Factor w/ 52 levels "Aalborg","Aizu",..: 9 31 50 15 49 39 36 40 12 46 ...
$ north: Factor w/ 52 levels "20d45'S","22d43'S",..: 8 18 41 7 1 3 2 4 43 29 ...
$ east : Factor w/ 51 levels "0d10'W","118d15'W",..: 19 16 20 35 31 32 34 33 11 39 ...
$ loc  : Factor w/ 30 levels "Australia","Austria",..: 1 1 2 3 3 3 3 3 4 19 ...
$ long : num  153 145 16.3 -49.3 -42.9 ...
$ lat  : num  -27.5 -37.8 48.2 -25.4 -20.8 ...
dario
  • 6,415
  • 2
  • 12
  • 26