Beruflich Dokumente
Kultur Dokumente
subarch=.Platform$r_arch)
source: creates a script that can be saved and run
Commands are separated by a ; or by a new line.
# signifies a comment which is not executed
To get help regarding a command type ?
before it.
Things are assigned to and stored
in objects using <
or =. A list of all objects in the current session can
be obtained by typing ls()
To remove objects type:remove(object,list=character(),inherits=FALSE)
we use the x
lsx and rjava packages.
i.e.
dat.xls<read.xlsx(addressofdata.xlsx,sheetIndex=1)
If you have trouble getting it working, just click "save as" in Excel and export the data to a comma
separated values file (.csv).
The XML package is for importing XML and HTML files. (use function: readHTMLTable)
To view your data as a whole: V
iew(nameofobject)
To view the first couple of rows: head(object)
To view the last couple of rows: tail(object)
To view the variable names: c
olnames(object)
Data sets in R are typically stored as d
ata frames in a matrix structure.
To access individual data points type in object[row,column]
Row:object[row,]
Column:object[,column]
pointsplots
Important packages:
map; mapdata; mapproj;
Other mapping packages
BIOS205
helpful details:
spaces dont matter
PUT COMMENTS (using #) in the scripts file
R precedence to operators
In R, there are two assignment operators. They have subtly different meanings
< requires that you type two characters
= is easier to type
CASE MATTERS
tab completion i.e. put part of a command and then hit tab and it will help you find the command
you are looking for.
brackets operator is used for indexing. R starts counting vector indices from 1.
mathematical commands:
atan is the oneargument arctangent
log is natural log
* is for multiplication
use a colon to easily create a new vector from one number to another with a stepsize of 1.
Using c to create a vector. Keep in mind input is different from output.
>x<c(9,12,6,10,10,16,8,4)
>x
[1]912610101684
>length(x)
[1]8
>sum(x)
[1]75
>sum(x)/length(x)
[1]9.375
>mean(x)
[1]9.375
logical values are either TRUE or FALSE. >= asks if the values in the vector are larger than the
indicated value.
>x>=1
[1]TRUETRUETRUETRUETRUETRUETRUETRUE
seq is the function equivalent of the colon operator
arguments can be specified by position, with one supplied argument for each name in the function
parameter list, and in the same order.
>1:5
[1]12345
>seq(1,5)
[1]12345
>seq(from=1,to=5)
[1]12345
str shows the internal structure of a data frame, including the type of each column.