User Tools

Site Tools


r:getting_started

This is an old revision of the document!


Installation, base

Windows

  1. Open http://www.r-project.org/ in your browser.
  2. Click on “CRAN”. You’ll see a list of mirror sites, organized by country.
  3. Select a site near you.
  4. Click on “Windows” under “Download and Install R”.
  5. Click on “base”.
  6. Click on the link for downloading the latest version of R (an .exe file).
  7. When the download completes, double-click on the .exe file and answer the usual questions.

OS X

  1. Open http://www.r-project.org/ in your browser.
  2. Click on “CRAN”. You’ll see a list of mirror sites, organized by country.
  3. Select a site near you.
  4. Click on “MacOS X”.
  5. Click on the .pkg file for the latest version of R, under “Files:”, to download it.
  6. When the download completes, double-click on the .pkg file and answer the usual questions.

Linux or Unix
The major Linux distributions have packages for installing R. Here are some examples:

Distribution Package name
Ubuntu or Debian r-base
Red Hat or Fedora R.i386
Suse R-base

Use the system’s package manager to download and install the package. Normally, you will need the root password or sudo privileges; otherwise, ask a system administrator to perform the installation.

Starting R

Windows

  • Click on Start → All Programs → R; or
  • double-click on the R icon on your desktop (assuming the installer created an icon for you).

OS X

  • Either click on the icon in the Applications directory or
  • put the R icon on the dock and click on the icon there.
  • Alternatively, you can just type R on a Unix command line in a shell.

Linux or Unix

  • Start the R program from the shell prompt using the R command (uppercase R).

Entering commands

> 1+1
> 1+1
[1] 2
max(1,3,5) 
[1] 5 
max(1,3
,5) 
[1] 5 

Table 1-1. Keystrokes for command-line editing

Labeled key Ctrl-key combination Effect
Up arrow Ctrl-P Recall previous command by moving backward through the history of commands.
Down arrow Ctrl-N Move forward through the history of commands.
Backspace Ctrl-H Delete the character to the left of cursor.
Delete (Del) Ctrl-D Delete the character to the right of cursor.
Home Ctrl-A Move cursor to the start of the line.
End Ctrl-E Move cursor to the end of the line.
Right arrow Ctrl-F Move cursor right (forward) one character.
Left arrow Ctrl-B Move cursor left (back) one character.
Ctrl-K Delete everything from the cursor position to the end of the line.
Ctrl-U Clear the whole darn line and start over.
Tab Name completion (on some platforms).

Exiting from R

On all platforms, you can also use the q function (as in quit) to terminate the program.

> q() 

Note the empty parentheses, which are necessary to call the function.

Windows

  • Select File → Exit from the main menu; or click on the red X in the upper-right corner of the window frame.

OS X

  • Press CMD-q (apple-q); or click on the red X in the upper-left corner of the window frame.

Linux or Unix

  • At the command prompt, press Ctrl-D.

Getting help

Use the help.start function to see the documentation’s table of contents:

 > help.start() 
 > help.start()
starting httpd help server ... done
If nothing happens, you should open
‘http://127.0.0.1:25578/doc/html/index.html’ yourself

start.help()

Packages
Click here to see a list of all the installed packages, both in the base packages and the additional, installed packages. Click on a package name to see a list of its functions and datasets.
Search Engine & Keywords
Click here to access a simple search engine, which allows you to search the documentation by keyword or phrase. There is also a list of common keywords, organized by topic; click one to see the associated pages.

Getting help from functions

Use help to display the documentation for the function:

 > help(functionname) 

Use args for a quick reminder of the function arguments:

 > args(functionname) 

Use example to see examples of using the function:

 > example(functionname) 
 > help(mean) 
 > ?mean 
 > args(mean) 
 > example(mean) 
r/getting_started.1473235287.txt.gz · Last modified: 2016/09/07 16:31 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki