R part 1
Posted on April 22, 2015
- Getting help: Use
?blah
ifblah
exists,??blah
to search ifblah
exists,help.search("blah")
can be also used. - R syntax is very similar to C. In R for global assignment use
<<-
, e.g.,x <<- 1
will make the value of global variablex
as 1, whereas ifx <- 1
makes a local variablex
whose value will be 1. x
Some useful R functions
|runif
| For generating uniform random variable | | cat
| For formatting output | | sqrt
| Square root | | hist
| Histogram, e.g., hist(xs, breaks = 10, main = "LCG", col = "grey")
| | plot
| Plotting \(xy\), e.g., plot(xs, ys, cex = 0.1, xlab = "X", ylab = "Y")
| | rpois
| Poisson random variable | | exp
| Exponential function | | log
| Logarithmic function |