From 22ef01829779c56eb1ae42c230efc78086aa7391 Mon Sep 17 00:00:00 2001 From: "M.Redondo" Date: Tue, 29 Oct 2024 22:47:01 +0100 Subject: [PATCH] updated loop slides --- slide_r_elements_4.Rmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slide_r_elements_4.Rmd b/slide_r_elements_4.Rmd index 39f87fe..295aa03 100644 --- a/slide_r_elements_4.Rmd +++ b/slide_r_elements_4.Rmd @@ -444,8 +444,8 @@ Let's see a simple example of a function to add one to a number: ```{r functions1, echo=T,error=T} add.one <- function(arg1) { - arg1 <- arg1 + 1 - return(arg1) + result <- arg1 + 1 + return(result) } add.one(1) ``` @@ -460,8 +460,8 @@ Sometimes, it is good to use default values for some arguments: ```{r functions2, echo=T, error=T} add.a.num <- function(arg, num=1) { - arg <- arg + num - return(arg) + result <- arg + num + return(result) } add.a.num(1) # skip the num argument