10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Data 71.2.3 AssignmentIt is often convenient to name a value so that we can use it later. Doing so is calledassignment. Assigment is straight<strong>for</strong>ward. We put a name on the left-hand side of theequals sign and the value on the right. Assignment does not produce any printed output.> x = 2 # assignment is quiet> x + 3 # x is now 2[1] 5> pi # pi is a built-inconstant[1] 3.142> e^2 # e is notError: Object “e” not found> e = exp(1) # e is now its familiarvalue> e^2[1] 7.389The variable e is not previously assigned, unlike the built-in constant pi. If we insistthough, we can assign it as illustrated.Assignment with=versus AReallySmallNumber = 0.000000001Case is important. Some variable names are naturally used to represent certain types ofdata. Often n is <strong>for</strong> a length; x or y stores a data vector; and i and j are <strong>for</strong> integers and

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!