I will most likely get the equipment data by the end of December. My mentor did say that I may not get it because it is hard to get classified information passed the security department at the marines. If I end up not getting it, my mentor is going to generate random numbers so that I could build my function. In theory, my code should work on the actual data.
I learned more about the R programming language. I need to be really comfortable with it so that I won't struggle with creating the algorithm as much. I reviewed the basic methods.
The print method allows me to view my data at any point I want. All I have to do is print it. That is useful because I can check the status of my data frequently, so I can see if I made a mistake anywhere in the process.
The cat function allows me to print multiple objects, something that the print function cannot do. However, it cannot print " compound data structures such as matrices and lists."
To instantiate a variable, use <- or -> to set it to any value you want. You can even change the variable from an integer to a list to a String. <<- makes the variable a global variable.
The rm function deletes variables. You cannot undo this action!
The c(...) function allows me to create vectors. It works with both vectors and non-vectors.
Section 2.6 of the R Cookbook discusses coding basic statistics in R.
"Use one of these functions as applies, assuming that x and y are vectors:
• mean(x)
• median(x)
• sd(x)
• var(x)
• cor(x, y)
• cov(x, y)"
The cor(x,y) function finds the correlation and cov(x,y) finds the covariance.
Below is a table from the R Cookbook that lists the operator precedence in R.
"Table 2-1. Operator precedence
Operator Meaning See also
[ [[ Indexing Recipe 2.9
:: ::: Access variables in a name space
$ @ Component extraction, slot extraction
^ Exponentiation (right to left)
- + Unary minus and plus
: Sequence creation Recipe 2.7, Recipe 7.14
%any% Special operators Discussion
* / Multiplication, division Discussion
+ - Addition, subtraction
== != < > <= >= Comparison Recipe 2.8
! Logical negation
& && Logical “and”, short-circuit “and”
| || Logical “or”, short-circuit “or”
~ Formula Recipe 11.1
-> ->> Rightward assignment Recipe 2.2
= Assignment (right to left) Recipe 2.2
<- <<- Assignment (right to left) Recipe 2.2
? Help Recipe 1.7
"
MORE OPERATORS
"%% Modulo operator
%/% Integer division
%*% Matrix multiplication
%in% Returns TRUE if the left operand occurs in its right operand; FALSE otherwise"
DEFINING A FUNCTION
"function(param1, ..., paramN) {
expr1
.
.
.
exprM
}"
Sources Used:
Teetor, P. (2011). R Cookbook [PDF file]. Sebastopol, California: O'Reilly Media, Inc. Retrieved from My Mentor.
http://stanford.edu/~jgrimmer/RDataManagement.pdf
Comments
Post a Comment