Created
March 3, 2012 19:17
-
-
Save xquery/1967597 to your computer and use it in GitHub Desktop.
Learning R - some basics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| R is an object-oriented language with every object having a type (and being a member of a class) | |
| *** What is R written in ? | |
| R itself, c and fortran (autoconf, shell script) | |
| http://blog.revolutionanalytics.com/2011/08/what-language-is-r-written-in.html | |
| though some R packages are in c++, Perl, etc | |
| *** basics | |
| > R | |
| starts everything | |
| >q() | |
| quits | |
| >help() | |
| will give you some help | |
| ***** basic math funcs | |
| >exp(1) | |
| 2.71828182845905 | |
| ***** range of numbers | |
| > x <- 1:3 | |
| | 1 | | |
| | 2 | | |
| | 3 | | |
| ***** define functions | |
| > x <- 1:5 | |
| > square <- function(x) { | |
| > x^2 | |
| > } | |
| > square(x) | |
| | 1 | | |
| | 4 | | |
| | 9 | | |
| | 16 | | |
| | 25 | | |
| ***** easy to define vector (arrays) and get specific member | |
| > b <- c(1,2,3,4,5,4343,7,8,9,10,11,12) | |
| > b[6] | |
| 4343 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment