Site Tools


notes:r_cheat_sheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
notes:r_cheat_sheet [2026/06/13 01:55]
110.39.161.109 old revision restored (2026/06/04 18:32)
notes:r_cheat_sheet [2026/06/13 19:09] (current)
188.235.16.74 old revision restored (2026/06/05 07:31)
Line 20: Line 20:
   * ''myseq[3]'' to access third element i.e. vectors indexed starting at 1.   * ''myseq[3]'' to access third element i.e. vectors indexed starting at 1.
   * Use a vector as an index to access multiple elements e.g. ''myseq[c(1,3)]''   * Use a vector as an index to access multiple elements e.g. ''myseq[c(1,3)]''
-  * The ''names'' function can be used to assign names to vector elements. Once names are asigned, they can be sed as indices e.g. <code>+  * The ''names'' function can be used to assign names to vector elements. Once names are asigned, they can be used as indices e.g. <code>
 names(myseq)=c('one','two','three') names(myseq)=c('one','two','three')
 myseq['two']</code> myseq['two']</code>
Line 28: Line 28:
 ===== Plotting ===== ===== Plotting =====
  
-  * ''barplot[myseq]'' creates a bar plot of the ''myseq'' vector.+  * ''barplot[myseq]'' creates a bar plot of the ''myseq'' vector. ''abline(h=y)'' plots a horizontal line at height y.
   * ''plot[x,y]'' plots x vs y e.g. <code>   * ''plot[x,y]'' plots x vs y e.g. <code>
 x=seq[0,20,.1] x=seq[0,20,.1]
Line 43: Line 43:
   * dim(myseq) can be used to change dimensions of a matrix   * dim(myseq) can be used to change dimensions of a matrix
   * ''mymatrix[3,4]'' returns an element of the matrix (row,column).   * ''mymatrix[3,4]'' returns an element of the matrix (row,column).
-  * ''mymatrix[,2] returns entire second column.+  * ''mymatrix[,2]'' returns entire second column.
  
 +===== Statistics =====
 +
 +  * ''mean(myvec)  median(myvec)   sd(myvec)''
 ===== File Handling ===== ===== File Handling =====
  
   * ''list.files()'' to list files in furrent directory   * ''list.files()'' to list files in furrent directory
   * ''source("file.R")'' to load file of code   * ''source("file.R")'' to load file of code
notes/r_cheat_sheet.1781340940.txt.gz · Last modified: 2026/06/13 01:55 by 110.39.161.109