For an assignment, I have to write a simple function, store it in a separate file, and use it in an exercise.
How do I store/save a function in a separate file? I'm sure this is very simple, but I can't seem to find it (complete newbie at R, if you haven't guessed yet).
The function is:
seconds2hours <- function(duration){
result <- duration / 3600
return(result)
}
type
?source
In the R console, to read about the source function
1 Like
as @nirgrahamuk said, place it in a different file, i.e. Myfunction.R
(I often place them in a file called utils.R
in the scripts folder of each project) and call it using source(Myfunction.R)
1 Like
Thanks for the tips!!
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.