Discussion 03 - Function

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

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

View Full Document Right Arrow Icon
Masanao Yajima
Background image of page 1

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

View Full DocumentRight Arrow Icon
Function definition is yet another special function. It takes parameter definition and Function body And returns a function object
Background image of page 2
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 ){
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

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

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 Right Arrow Icon
Ask a homework question - tutors are online