lucasn
lucasn

Reputation: 137

Import stuff from a R file

I'm studying R, and I was asked to use the pi2000 data set, available at the simpleR library (http://www.math.csi.cuny.edu/Statistics/R/simpleR/index.html/simpleR.R). Then I downloaded this file. How do I import it to the command line?

Upvotes: 8

Views: 8375

Answers (2)

Alex Reynolds
Alex Reynolds

Reputation: 96937

Do you mean load the function into R? If so, use source():

source("http://www.math.csi.cuny.edu/Statistics/R/simpleR/index.html/simpleR.R")

Upvotes: 6

Alex Brown
Alex Brown

Reputation: 42872

Use the source function:

> source("http://www.math.csi.cuny.edu/Statistics/R/simpleR/index.html/simpleR.R")

You can then access the variables defined there:

> vacation
 [1] 23 12 10 34 25 16 27 18 28 13 14 20  8 21 23 33 30 13 16 14 38 19  6 11 15 21 10
[28] 39 42 25 12 17 19 26 20

for more information, type ?source into an R terminal.

Upvotes: 19

Related Questions