Create the following r source file on a certain directory.
SumF <- function(a,b){ return(a+b) } |
# specify the path to the .r file sf <- "H:/Quantitative Research/R/SumF.r" sf # load and run the code from the file source(sf) SumF(1,2) |
[1] 3 |
Mean (average)
Create the following r source file on a certain directory.
MeanF <- function(a,b){ return(mean(c(a,b))) } |
# specify the path to the .r file mf <- "H:/Quantitative Research/R/MeanF.r" mf # load and run the code from the file source(mf) MeanF(1,2) |
[1] 1.5 |
No comments:
Post a Comment