05.12.2012 Views

What documentation exists for R?

What documentation exists for R?

What documentation exists for R?

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7: R Miscellanea 89<br />

R> as.list(quote(-2^2))<br />

[[1]]<br />

‘-‘<br />

[[2]]<br />

2^2<br />

7.34 How can I save the result of each iteration in a loop<br />

into a separate file?<br />

One way is to use paste() (or sprintf()) to concatenate a stem filename and the iteration<br />

number while file.path() constructs the path. For example, to save results into files<br />

‘result1.rda’, . . ., ‘result100.rda’ in the subdirectory ‘Results’ of the current working<br />

directory, one can use<br />

<strong>for</strong>(i in 1:100) {<br />

## Calculations constructing "some_object" ...<br />

fp

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!