Jon Duan
Nov. 14 2015
http://ateucher.github.io/rcourse_site/basics.html https://github.com/ateucher/rcourse_site
http://ateucher.github.io/rcourse_site/basics.html
Understanding basic data types in R
R has 6 (although we will not discuss the raw class for this workshop) data types.
"a"
, "swc"
2
, 15.5
2L
(the L
tells R to store this as an integer)TRUE
, FALSE
1+4i
(complex numbers with real and imaginary parts)R has many data structures. The main ones are:
Other options you can add to the tag
http://rmarkdown.rstudio.com/authoring_rcodechunks.html
Option | Description |
---|---|
echo = TRUE or FALSE | to show or hide code. |
eval = TRUE or FALSE | to run or skip the code. |
warning = TRUE or FALSE | to show or hide function warnings. |
message = TRUE or FALSE | to show or hide function R messages. |
results = “hide” | will hide results. They will still be executed |
fig.height = | Height of figure |
fig.width = | width of figure |
x = 'hello, python world!'
print(x.split(' '))
['hello,', 'python', 'world!']
library(knitr)
opts_chunk$set(cache = TRUE)
#include <Rcpp.h>
// [[Rcpp::export]]
int fibonacci(const int x) {
if (x == 0 || x == 1) return(x);
return (fibonacci(x - 1)) + fibonacci(x - 2);
}
RStudio and IPython Notebook,
Individual documents are easily placed under version control and shared with colleagues via email, GitHub, or online hosting services like RPubs and IPyNb Viewer.
The default notebook presentation style is to show the code cells with the numbered In []: and Out []: block numbering, but it presumably only takes a small style extension or customisation to suppress that? And another small extension to add the ability to hide a code cell and just display the output?