{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Week 2 Jan 18.pdf - Week 2 Jan 18 Monday 2:58 PM Scripts...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Write scripts/functions using text editors (.txt file required) >source(" ", echo=TRUE) will read your script/function and explicitly state results Scripts typically good for simple things Scripts Consider f(a,b,c) Specifies how to compute an output (value) from one or more inputs (arguments/parameters) Can be assigned to variable or used in arithmetic Example: 'angle' is the argument of this function >sin_deg <- function(angle) sin(angle*pi/180) #sin_deg = f(angle) >sin_deg(30) + 100find [1] 100.5 Example: Vector Arguments >distance <-function(a,b) sqrt( (a[1]-b[1] )^2 + (a[2]-b[2])^2)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}