{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Discussion 03 - Function

# Discussion 03 - Function - addedval = p1 p2 p3 return...

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

Masanao Yajima

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

View Full Document
Function definition is yet another special function. It takes parameter definition and Function body And returns a function object
Notice it looks very similar to making vector or matrix. Only difference is the part in {} which is the function body. A <- c( 1, 2, 3 ) B <- matrix( 0, 2, 3 ) add3 <- function( p1, p2, p3 ){

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: addedval = p1 + p2 + p3 return( addedval ) } add3 <- function( p1, p2, p3 ){ addedval = p1 + p2 + p3 return( addedval ) } A <- 1 B <- 2 C <- 3 D <- add3( A, B, C ) D 6 Function add3 B C P1 P2 P3 A addedval return D 1 2 3 6 sd1 <- function( x ) { sqrt( sum( ( x - mean( x ) ) ^ 2 ) / length( x ) ) } sd.R...
View Full Document

{[ snackBarMessage ]}

### Page1 / 6

Discussion 03 - Function - addedval = p1 p2 p3 return...

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

View Full Document
Ask a homework question - tutors are online