Читать книгу Probability with R - Jane M. Horgan - Страница 48

2.4.2 Scripts

Оглавление

There are various ways of developing programs in R.

The most useful way of writing programs is by means of R 's own built‐in editor called . From at the toolbar click on New Script (File/New Script). You are then presented with a blank screen to develop your program. When done, you may save and retrieve this program as you wish. File/Save causes the file to be saved. You may designate the name you want to call it, and it will be given a .R extension. In subsequent sessions, File/Open Script brings up all the .R files that you have saved. You can select the one you wish to use.

When you want to execute a line or group of lines, highlight them and press Ctrl/R, that is, Ctrl and the letter R simultaneously. The commands are then transferred to the control window and executed.

Alternatively, if the program is short, it may be developed interactively while working at your computer.

Programs may also be developed in a text editor, like Notepad, saved with the .R extension and retrieved using the source statement.

source("C:\\test")

retrieves the program named test.R from the C directory. Another way of doing this, while working in R, is to click on on the tool bar where you will be given the option to Source R code, and then you can browse and retrieve the program you require.

Probability with R

Подняться наверх