R part 1
Posted on April 22, 2015
- Getting help: Use
?blahifblahexists,??blahto search ifblahexists,help.search("blah")can be also used. - R syntax is very similar to C. In R for global assignment use
<<-, e.g.,x <<- 1will make the value of global variablexas 1, whereas ifx <- 1makes a local variablexwhose 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 |