moreR_4perPage

# moreR_4perPage - More Classification in R Data Mining Prof....

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: More Classification in R Data Mining Prof. Dawn Woodard School of ORIE Cornell University 1 Outline 1 Announcements 2 Workspaces 3 Writing Functions and Loops 4 Homework 2 Announcements ... 4 R Workspace The objects currently in the workspace can be listed using the ls() command You can remove an object by calling e.g. remove( a ) I like to clear the workspace occasionally so that I do not mistakenly refer to the wrong object > remove( list=ls() ) 6 Homework due Tuesday Part I: You will need to write a function to predict based on your classification tree Part II: You will improve your classification rule 8 Functions in R Define a simple function: myFun <- function(a) { print( sum(a) ) return( mean(a) ) } Call your function. Whats the result? b <- myFun( (1:4) ) b 9 Functions in R A functions scope means the set of objects that you can refer to inside the function. myFun <- function(a) { print( sum(a) ) return( mean(a) ) } What is the scope of myFun? 10 Functions in R Unfortunately in R, inside a function it is possible to refer to objects that are not arguments to that function > b <- 2 > myFun <- function() { b } > myFun() [1] 2 I do NOT want you to do this It can cause terrible bugs 11 Nested Functions Functions can call other functions: myFun1 <- function(c) { return( c+2 ) } myFun2 <- function(a) { print( sum(a) ) d <- myFun1( a )...
View Full Document

## This note was uploaded on 12/23/2009 for the course ORIE 4740 at Cornell University (Engineering School).

### Page1 / 7

moreR_4perPage - More Classification in R Data Mining Prof....

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online