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

Info icon This 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)
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern