How to use R 2

My first introduction about how to use R is here.

I have attended in the Workshop hosted by UVa library statistics consulting group. It was useful for me because they provide the detailed descriptions and explanations about each code. Because my first experience of R did not include any of those step-by-step explanations about how to use R. This workshop provided explanations of the each code in the SCRIPTS window with “#”. And by clicking ctrl + enter, the results of running those code were show in the CONSOLE, so that I could follow easily what I was doing with R.

I have summarized my notes below:

  • ctrl +enter: bring codes from scripts to console
  • write down orders in R script (upper left) and click ctrl+enter to see the results in the Console
  • remove
    • # the rm function removes objects from memory
    • rm(x, y, z)
    • or broom mark upper right where s,y,z showed
  • Setting working directory
    • [menu] session–> set working directory
    • tab key will call folder to put ” “
  • names: name of the columns
  • nrow: number of rows
  • ncol: cumber of columns.
  • $ will help to see certain culumns
  • can calculate frequencies or numeric
  • to see the numbers put the order in the ( )
  • subsetting : use [ ]
  • c( ): select columns (name of the column) # for example, c(company, sales)
  • save the file as .Rda by selecting sections and saved it as new name

Using R

R uses commands

  • Two parts of commands in R: objects and functions and these are separated by ‘ <- ‘, means ‘is created from’.
    • Objects: could be a single or collections of variable (s), stat model.
    • Functions: things that I do in R to create my objects
    • For example, object <- function = object is created from function.
  • Concatenate function c() : make groups together
  • Importing Data: most commonly used R-friendly formats are tab-delimted text(.txt in Excel and .dat in SPSS)


  1. I can put more than one command on a single line if I prefer.
  2. R is case sensitive: capital letter and small letter

Here are some useful links for R

Regression Commands

Vector support machines (April recommended during the WS)

Support vector machine in R (useful article-April recommended)  (can share data-April recommended)

How to read scatterplot matrix in R?

MOOC (Coursera): R programming (4 weeks): Jul/7-Aug/4, 2014



A. Field, J. Miles, Z. Field (2012). Discovering Statistics using R. Sage.