Collection of Basic R

Post date: Jun 29, 2013 7:02:02 PM

Plot and Graphics

  • hist: build histogram
  • How to plot 2 histograms on the same plot [url]
  • title: make title
  • Plot points with different colors defined by its value [url]

Data

  • convert factor to integer [url, url2]
  • change the column name in a data frame [url]
    • to list the column names -- colnames(DF), names(DF)
  • NA (not available), how to deal with NA [url]
  • The difference between "[" and "[[" in list.
    • some explanation from stackoverflow [url]
    • my simple example.
  • Write to csv file [url]
  • Save and Load file in R [url]
  • Convert a data frame into a numeric matrix [url]

Functions

  • Make a function in R [url]
  • It is possible to make a separate file for functions. When want to use the function, you will need to run the function before running your main code, so that the function is loaded into the workspace.
  • How to chain "if", "if else" and "else" statement [url]

String and Text

  • How to concatenate a vector of characters or strings [url]

R Console

  • clear screen console: Ctrl+L (for Windows). However, for any system you might want to read this.
  • How to remove all variables, but not function, from the workspace. [url]