Law Law - 13 days ago 4x
R Question

Source a file into R

In the book A first course in statistical programming with R by W. John Braun and Duncan J. Murdoch, there's an exercise asking :

Use a text editor to create a file consisting of the line
randomdata <-
c(64, 38, 97, 88, 24, 14, 14, 104, 83)
. Save it to a file called

In my opinion, I've succeed this exercise. I used the software TextEdit, I wrote the command
randomdata <- c(64, 38, 97, 88, 24, 14, 14, 104, 83)
and I saved the file as
. Did I do it right?

The second question, they ask the question :

Source the file
into R and confirm the
was created.

Could anyone be able to explain to me what is asked for? Some hints would be sufficient.

P.S. I'm using a Macbook Pro 2012.


1) Yes you did it right.

2) You simply have to use source to execute all the codes lines that are in your file. In this case: source('randomdata') (assuming you created it in your working directory).

Note: it's better to name your file randomdata.R.